summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-09-01 20:15:25 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-09-01 20:15:25 +0000
commit30fc9a9339de86b098667a8fa9eba6da1f7232d2 (patch)
tree25f064f28b750b3429481711358cf4ebbc895ac4 /clang/lib/Sema/SemaDecl.cpp
parent2fa35194632ce6ebfa2d6782afd62e1274d2e225 (diff)
downloadbcm5719-llvm-30fc9a9339de86b098667a8fa9eba6da1f7232d2.tar.gz
bcm5719-llvm-30fc9a9339de86b098667a8fa9eba6da1f7232d2.zip
When we reach the end of a #include of a header of a local submodule that we
textually included, create an ImportDecl just as we would if we reached a #include of any other modular header. This is necessary in order to correctly determine the set of variables to initialize for an imported module. This should hopefully make the modules selfhost buildbot green again. llvm-svn: 280409
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 8b148af8cce..2a514ab1bd2 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -15312,7 +15312,10 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
void Sema::ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod) {
checkModuleImportContext(*this, Mod, DirectiveLoc, CurContext, true);
+ BuildModuleInclude(DirectiveLoc, Mod);
+}
+void Sema::BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod) {
// Determine whether we're in the #include buffer for a module. The #includes
// in that buffer do not qualify as module imports; they're just an
// implementation detail of us building the module.
@@ -15352,20 +15355,27 @@ void Sema::ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod) {
VisibleModules.setVisible(Mod, DirectiveLoc);
}
-void Sema::ActOnModuleEnd(SourceLocation DirectiveLoc, Module *Mod) {
- checkModuleImportContext(*this, Mod, DirectiveLoc, CurContext);
+void Sema::ActOnModuleEnd(SourceLocation EofLoc, Module *Mod) {
+ checkModuleImportContext(*this, Mod, EofLoc, CurContext);
if (getLangOpts().ModulesLocalVisibility) {
- assert(!ModuleScopes.empty() && ModuleScopes.back().Module == Mod &&
- "left the wrong module scope");
VisibleModules = std::move(ModuleScopes.back().OuterVisibleModules);
- ModuleScopes.pop_back();
-
- VisibleModules.setVisible(Mod, DirectiveLoc);
// Leaving a module hides namespace names, so our visible namespace cache
// is now out of date.
VisibleNamespaceCache.clear();
}
+
+ assert(!ModuleScopes.empty() && ModuleScopes.back().Module == Mod &&
+ "left the wrong module scope");
+ ModuleScopes.pop_back();
+
+ // We got to the end of processing a #include of a local module. Create an
+ // ImportDecl as we would for an imported module.
+ FileID File = getSourceManager().getFileID(EofLoc);
+ assert(File != getSourceManager().getMainFileID() &&
+ "end of submodule in main source file");
+ SourceLocation DirectiveLoc = getSourceManager().getIncludeLoc(File);
+ BuildModuleInclude(DirectiveLoc, Mod);
}
void Sema::createImplicitModuleImportForErrorRecovery(SourceLocation Loc,
OpenPOWER on IntegriCloud