diff options
| author | Ben Langmuir <blangmuir@apple.com> | 2015-02-12 21:51:31 +0000 |
|---|---|---|
| committer | Ben Langmuir <blangmuir@apple.com> | 2015-02-12 21:51:31 +0000 |
| commit | 18dd78a8fd7077398e6c89cc0bee6c144e936408 (patch) | |
| tree | 754f7f0585fff5cdc6a3dfe50d811153c2ea4a5a /clang/lib | |
| parent | 39e988c63cf1cb8f68cb6d7e9c70e13e4b6050bc (diff) | |
| download | bcm5719-llvm-18dd78a8fd7077398e6c89cc0bee6c144e936408.tar.gz bcm5719-llvm-18dd78a8fd7077398e6c89cc0bee6c144e936408.zip | |
Mangle the IsSystem bit into the .pcm file name
When mangling the module map path into a .pcm file name, also mangle the
IsSystem bit, which can also depend on the header search paths. For
example, the user may change from -I to -isystem. This can affect
diagnostics in the importing TU.
llvm-svn: 228966
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Frontend/FrontendActions.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Lex/HeaderSearch.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/Serialization/ASTReader.cpp | 7 | ||||
| -rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 1 |
4 files changed, 17 insertions, 3 deletions
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index 701ef026d49..e7ecb2952ac 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -366,7 +366,7 @@ bool GenerateModuleAction::ComputeASTConsumerArguments(CompilerInstance &CI, HeaderSearch &HS = CI.getPreprocessor().getHeaderSearchInfo(); CI.getFrontendOpts().OutputFile = HS.getModuleFileName(CI.getLangOpts().CurrentModule, - ModuleMapForUniquing->getName()); + ModuleMapForUniquing->getName(), IsSystem); } // We use createOutputFile here because this is exposed via libclang, and we diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index d6b255fb014..f76d851ac6c 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -115,11 +115,13 @@ const HeaderMap *HeaderSearch::CreateHeaderMap(const FileEntry *FE) { std::string HeaderSearch::getModuleFileName(Module *Module) { const FileEntry *ModuleMap = getModuleMap().getModuleMapFileForUniquing(Module); - return getModuleFileName(Module->Name, ModuleMap->getName()); + return getModuleFileName(Module->Name, ModuleMap->getName(), + Module->IsSystem); } std::string HeaderSearch::getModuleFileName(StringRef ModuleName, - StringRef ModuleMapPath) { + StringRef ModuleMapPath, + bool IsSystem) { // If we don't have a module cache path, we can't do anything. if (ModuleCachePath.empty()) return std::string(); @@ -147,6 +149,10 @@ std::string HeaderSearch::getModuleFileName(StringRef ModuleName, llvm::hash_code Hash = llvm::hash_combine(DirName.lower(), FileName.lower()); + // Hash the IsSystem bit, since changing search paths can change whether a + // module is considered 'system' or not. + Hash = llvm::hash_combine(Hash, IsSystem); + SmallString<128> HashStr; llvm::APInt(64, size_t(Hash)).toStringUnsigned(HashStr, /*Radix*/36); llvm::sys::path::append(Result, ModuleName + "-" + HashStr.str() + ".pcm"); diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index aa1cdc080ee..fe5c71fafc8 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -3435,6 +3435,13 @@ ASTReader::ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F, << F.ModuleName << /*not new*/1 << ModMap->getName(); return OutOfDate; } + + // Check whether the 'IsSystem' bit changed. + if (M->IsSystem != static_cast<bool>(Record[Idx])) { + if ((ClientLoadCapabilities & ARR_OutOfDate) == 0) + Diag(diag::err_module_system_change) << F.ModuleName << M->IsSystem; + return OutOfDate; + } } if (Listener) diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index aad4305d8c5..2526c638d30 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -1215,6 +1215,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context, Record.push_back(0); } + Record.push_back(WritingModule->IsSystem); Stream.EmitRecord(MODULE_MAP_FILE, Record); } |

