summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index cdc9882d14e..1fa131f6276 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -15652,10 +15652,11 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
void Sema::ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod) {
checkModuleImportContext(*this, Mod, DirectiveLoc, CurContext, true);
- BuildModuleInclude(DirectiveLoc, Mod);
+ BuildModuleInclude(DirectiveLoc, Mod, false/*NoImport*/);
}
-void Sema::BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod) {
+void Sema::BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod,
+ bool NoImport) {
// 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.
@@ -15665,7 +15666,7 @@ void Sema::BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod) {
TUKind == TU_Module &&
getSourceManager().isWrittenInMainFile(DirectiveLoc);
- bool ShouldAddImport = !IsInModuleIncludes;
+ bool ShouldAddImport = !IsInModuleIncludes && !NoImport;
// If this module import was due to an inclusion directive, create an
// implicit import declaration to capture it in the AST.
@@ -15713,7 +15714,11 @@ void Sema::ActOnModuleEnd(SourceLocation EofLoc, Module *Mod) {
assert(File != getSourceManager().getMainFileID() &&
"end of submodule in main source file");
SourceLocation DirectiveLoc = getSourceManager().getIncludeLoc(File);
- BuildModuleInclude(DirectiveLoc, Mod);
+ // Do not create implicit ImportDecl if we are building the implementation
+ // of a module.
+ bool NoImport = Mod->getTopLevelModuleName() == getLangOpts().CurrentModule &&
+ !getLangOpts().isCompilingModule();
+ BuildModuleInclude(DirectiveLoc, Mod, NoImport);
}
void Sema::createImplicitModuleImportForErrorRecovery(SourceLocation Loc,
OpenPOWER on IntegriCloud