diff options
| author | Manman Ren <manman.ren@gmail.com> | 2017-01-11 00:48:19 +0000 |
|---|---|---|
| committer | Manman Ren <manman.ren@gmail.com> | 2017-01-11 00:48:19 +0000 |
| commit | 7f41c4d802bec54338f3108f2732c410746a50f2 (patch) | |
| tree | 8c2c15c8e014228daac28fcc972df1c875c713e2 /clang/lib/Sema/SemaDecl.cpp | |
| parent | a9054ddd9ccf8d1a94b4c2a8966bcf44874311ae (diff) | |
| download | bcm5719-llvm-7f41c4d802bec54338f3108f2732c410746a50f2.tar.gz bcm5719-llvm-7f41c4d802bec54338f3108f2732c410746a50f2.zip | |
Module: Do not create Implicit ImportDecl for module X if we
are building an implemenation of module X.
This fixes a regression caused by r280409.
rdar://problem/29930553
llvm-svn: 291628
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 13 |
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, |

