diff options
author | Ben Langmuir <blangmuir@apple.com> | 2016-02-05 01:10:05 +0000 |
---|---|---|
committer | Ben Langmuir <blangmuir@apple.com> | 2016-02-05 01:10:05 +0000 |
commit | e7d67575f237a5cae8cf5cba2389567ae9fa3a6d (patch) | |
tree | 5395e4b000c56ded647be935db2e8f413e0e55f7 /clang/lib/Sema/SemaDecl.cpp | |
parent | 5923973fe2c2c80cd11e67b34ba1fae03f87a9b0 (diff) | |
download | bcm5719-llvm-e7d67575f237a5cae8cf5cba2389567ae9fa3a6d.tar.gz bcm5719-llvm-e7d67575f237a5cae8cf5cba2389567ae9fa3a6d.zip |
Don't synthesize an ImportDecl for a module named in -fmodule-implementation-of
When building a PCH with modules enabled this import would assert in the
ASTWriter and (if assertions were disabled) sometimes crash the compiler
that loaded the resulting PCH when trying to lookup the submodule ID.
rdar://problem/24137448
llvm-svn: 259859
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 510e70aedb1..d26e5e18830 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -14783,9 +14783,15 @@ void Sema::ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod) { TUKind == TU_Module && getSourceManager().isWrittenInMainFile(DirectiveLoc); + // Similarly, if this module is specified by -fmodule-implementation-of + // don't actually synthesize an illegal module import. + bool ShouldAddImport = !IsInModuleIncludes && + (getLangOpts().ImplementationOfModule.empty() || + getLangOpts().ImplementationOfModule != Mod->getTopLevelModuleName()); + // If this module import was due to an inclusion directive, create an // implicit import declaration to capture it in the AST. - if (!IsInModuleIncludes) { + if (ShouldAddImport) { TranslationUnitDecl *TU = getASTContext().getTranslationUnitDecl(); ImportDecl *ImportD = ImportDecl::CreateImplicit(getASTContext(), TU, DirectiveLoc, Mod, |