summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2015-02-19 20:12:20 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2015-02-19 20:12:20 +0000
commitbd0b651bd249ab766f9c17cf4a9f5ef268f53632 (patch)
tree3aa21db58320d852de48f1eb76db2cfb32406da6 /clang/lib/Frontend
parentdfedfeb298ae491ff6f2f39ab33c01739177d365 (diff)
downloadbcm5719-llvm-bd0b651bd249ab766f9c17cf4a9f5ef268f53632.tar.gz
bcm5719-llvm-bd0b651bd249ab766f9c17cf4a9f5ef268f53632.zip
[PCH/Modules] Check that the specific module cache path the PCH was built with, is the same as
the one in the current compiler invocation. If they differ reject the PCH. This protects against the badness occurring from getting modules loaded from different module caches (see crashes). rdar://19889860 llvm-svn: 229909
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp20
-rw-r--r--clang/lib/Frontend/FrontendAction.cpp4
-rw-r--r--clang/lib/Frontend/FrontendActions.cpp2
3 files changed, 17 insertions, 9 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 187e2b78b8f..5d554b717b3 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -329,14 +329,7 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
PP->setPreprocessedOutput(getPreprocessorOutputOpts().ShowCPP);
- // Set up the module path, including the hash for the
- // module-creation options.
- SmallString<256> SpecificModuleCache(
- getHeaderSearchOpts().ModuleCachePath);
- if (!getHeaderSearchOpts().DisableModuleHash)
- llvm::sys::path::append(SpecificModuleCache,
- getInvocation().getModuleHash());
- PP->getHeaderSearchInfo().setModuleCachePath(SpecificModuleCache);
+ PP->getHeaderSearchInfo().setModuleCachePath(getSpecificModuleCachePath());
// Handle generating dependencies, if requested.
const DependencyOutputOptions &DepOpts = getDependencyOutputOpts();
@@ -373,6 +366,17 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
}
}
+std::string CompilerInstance::getSpecificModuleCachePath() {
+ // Set up the module path, including the hash for the
+ // module-creation options.
+ SmallString<256> SpecificModuleCache(
+ getHeaderSearchOpts().ModuleCachePath);
+ if (!getHeaderSearchOpts().DisableModuleHash)
+ llvm::sys::path::append(SpecificModuleCache,
+ getInvocation().getModuleHash());
+ return SpecificModuleCache.str();
+}
+
// ASTContext
void CompilerInstance::createASTContext() {
diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp
index 0bb5d87407b..75670d9a202 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -262,6 +262,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
FileManager &FileMgr = CI.getFileManager();
PreprocessorOptions &PPOpts = CI.getPreprocessorOpts();
StringRef PCHInclude = PPOpts.ImplicitPCHInclude;
+ std::string SpecificModuleCachePath = CI.getSpecificModuleCachePath();
if (const DirectoryEntry *PCHDir = FileMgr.getDirectory(PCHInclude)) {
std::error_code EC;
SmallString<128> DirNative;
@@ -273,7 +274,8 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
if (ASTReader::isAcceptableASTFile(Dir->path(), FileMgr,
CI.getLangOpts(),
CI.getTargetOpts(),
- CI.getPreprocessorOpts())) {
+ CI.getPreprocessorOpts(),
+ SpecificModuleCachePath)) {
PPOpts.ImplicitPCHInclude = Dir->path();
Found = true;
break;
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index e7ecb2952ac..c8673e50a05 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -501,9 +501,11 @@ namespace {
}
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
+ StringRef SpecificModuleCachePath,
bool Complain) override {
Out.indent(2) << "Header search options:\n";
Out.indent(4) << "System root [-isysroot=]: '" << HSOpts.Sysroot << "'\n";
+ Out.indent(4) << "Module Cache: '" << SpecificModuleCachePath << "'\n";
DUMP_BOOLEAN(HSOpts.UseBuiltinIncludes,
"Use builtin include directories [-nobuiltininc]");
DUMP_BOOLEAN(HSOpts.UseStandardSystemIncludes,
OpenPOWER on IntegriCloud