-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[NFC] Miscellaneous Cleanups To Clang Module Loading #32145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
|
@swift-ci test |
|
@swift-ci test source compatibility |
|
@swift-ci test source compatibility release |
|
Build failed |
|
Ah, the joys of non-deterministic diagnostics @swift-ci test macOS platform |
|
Build failed |
|
@swift-ci clean test macOS platform |
|
Build failed |
|
Fech, everything fell over. @swift-ci clean smoke test |
|
@swift-ci test source compatibility |
davidungar
left a comment
There was a problem hiding this 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.
| 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. |
There was a problem hiding this comment.
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.
|
⛵ |
getWrapperForModulein clang module loading.