Skip to content

Conversation

@CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Jun 2, 2020

  • Drop the overlay-forcing parameter. That's already happening when we populate the import cache.
  • Fold code duplicating getWrapperForModule in clang module loading.

CodaFi added 4 commits June 2, 2020 09:51
It's a touch cleaner to do this than passing around a pile of bools.
The only caller consuming the data that resulted from this bit has it
set to false. Additionally, the side effect of force-loading the
overlays is already handled unconditionally by the call to
namelookup::getAllImports.
@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 2, 2020

@swift-ci test

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 2, 2020

@swift-ci test source compatibility

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 2, 2020

@swift-ci test source compatibility release

@swift-ci
Copy link
Contributor

swift-ci commented Jun 2, 2020

Build failed
Swift Test OS X Platform
Git Sha - d2e1336

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 2, 2020

Ah, the joys of non-deterministic diagnostics

@swift-ci test macOS platform

@swift-ci
Copy link
Contributor

swift-ci commented Jun 2, 2020

Build failed
Swift Test OS X Platform
Git Sha - d2e1336

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 2, 2020

@swift-ci clean test macOS platform

@swift-ci
Copy link
Contributor

swift-ci commented Jun 2, 2020

Build failed
Swift Test OS X Platform
Git Sha - d2e1336

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 3, 2020

Fech, everything fell over.

@swift-ci clean smoke test

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 3, 2020

@swift-ci test source compatibility

Copy link
Contributor

@davidungar davidungar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks nice and clean. I don't know enough to vouch for its correctness, though.

Comment on lines -1809 to -1840
auto &cacheEntry = ModuleWrappers[clangModule];
ModuleDecl *result;
ClangModuleUnit *wrapperUnit;
if ((wrapperUnit = cacheEntry.getPointer())) {
result = wrapperUnit->getParentModule();
if (!cacheEntry.getInt()) {
// Force load overlays for all imported modules.
// FIXME: This forces the creation of wrapper modules for all imports as
// well, and may do unnecessary work.
cacheEntry.setInt(true);
(void) namelookup::getAllImports(result);
}
} else {
// Build the representation of the Clang module in Swift.
// FIXME: The name of this module could end up as a key in the ASTContext,
// but that's not correct for submodules.
Identifier name = SwiftContext.getIdentifier((*clangModule).Name);
result = ModuleDecl::create(name, SwiftContext);
result->setIsSystemModule(clangModule->IsSystem);
result->setIsNonSwiftModule();
result->setHasResolvedImports();

wrapperUnit =
new (SwiftContext) ClangModuleUnit(*result, *this, clangModule);
result->addFile(*wrapperUnit);
SwiftContext.getClangModuleLoader()
->findOverlayFiles(importLoc, result, wrapperUnit);
cacheEntry.setPointerAndInt(wrapperUnit, true);

// Force load overlays for all imported modules.
// FIXME: This forces the creation of wrapper modules for all imports as
// well, and may do unnecessary work.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to rid of all this stuff. I don't know the ClangImporter well enough to understand how we can afford to get rid of it, but I'll take your word for it.

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 3, 2020

@CodaFi CodaFi merged commit 1d0065d into swiftlang:master Jun 3, 2020
@CodaFi CodaFi deleted the port-of-call branch June 3, 2020 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants