diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-05-08 20:30:47 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-05-08 20:30:47 +0000 |
commit | 4a3751ff246394755e113f162435829b7d67d6ed (patch) | |
tree | 99e287c7f086be0e9c50f99b2b8783c91fba3a98 /clang/lib/Lex/ModuleMap.cpp | |
parent | c48c993b752a848016be06f73ca3dc797b09d6d6 (diff) | |
download | bcm5719-llvm-4a3751ff246394755e113f162435829b7d67d6ed.tar.gz bcm5719-llvm-4a3751ff246394755e113f162435829b7d67d6ed.zip |
If we are building a module, and we read a second description of the same
module from a different module map, ignore it.
This happens during builds of preprocessed modules (where it is harmless).
llvm-svn: 302463
Diffstat (limited to 'clang/lib/Lex/ModuleMap.cpp')
-rw-r--r-- | clang/lib/Lex/ModuleMap.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index 70d37d3d708..568894c32b9 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -1485,7 +1485,19 @@ void ModuleMapParser::parseModuleDecl() { // Determine whether this (sub)module has already been defined. if (Module *Existing = Map.lookupModuleQualified(ModuleName, ActiveModule)) { - if (Existing->DefinitionLoc.isInvalid() && !ActiveModule) { + // We might see a (re)definition of a module that we already have a + // definition for in two cases: + // - If we loaded one definition from an AST file and we've just found a + // corresponding definition in a module map file, or + bool LoadedFromASTFile = Existing->DefinitionLoc.isInvalid(); + // - If we're building a (preprocessed) module and we've just loaded the + // module map file from which it was created. + bool ParsedAsMainInput = + Map.LangOpts.getCompilingModule() == LangOptions::CMK_ModuleMap && + Map.LangOpts.CurrentModule == ModuleName && + SourceMgr.getDecomposedLoc(ModuleNameLoc).first != + SourceMgr.getDecomposedLoc(Existing->DefinitionLoc).first; + if (!ActiveModule && (LoadedFromASTFile || ParsedAsMainInput)) { // Skip the module definition. skipUntil(MMToken::RBrace); if (Tok.is(MMToken::RBrace)) |