summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/GeneratePCH.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2019-03-12 18:38:04 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2019-03-12 18:38:04 +0000
commit70d759b4eb958505a6893f2a64a0c1f613c95c2e (patch)
tree832d1e83afc38045e014cc317839ad3466fc9710 /clang/lib/Serialization/GeneratePCH.cpp
parent4ab0a9f0a4e7daff3fc54fd48d429c6c2017a458 (diff)
downloadbcm5719-llvm-70d759b4eb958505a6893f2a64a0c1f613c95c2e.tar.gz
bcm5719-llvm-70d759b4eb958505a6893f2a64a0c1f613c95c2e.zip
Modules: Add LangOptions::CacheGeneratedPCH
Add an option to cache the generated PCH in the ModuleCache when emitting it. This protects clients that build PCHs and read them in the same process, allowing them to avoid race conditions between parallel jobs the same way that Clang's implicit module build system does. rdar://problem/48740787 llvm-svn: 355950
Diffstat (limited to 'clang/lib/Serialization/GeneratePCH.cpp')
-rw-r--r--clang/lib/Serialization/GeneratePCH.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/clang/lib/Serialization/GeneratePCH.cpp b/clang/lib/Serialization/GeneratePCH.cpp
index 7c2ef5a13a1..6d98524636f 100644
--- a/clang/lib/Serialization/GeneratePCH.cpp
+++ b/clang/lib/Serialization/GeneratePCH.cpp
@@ -24,12 +24,14 @@ PCHGenerator::PCHGenerator(
const Preprocessor &PP, InMemoryModuleCache &ModuleCache,
StringRef OutputFile, StringRef isysroot, std::shared_ptr<PCHBuffer> Buffer,
ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
- bool AllowASTWithErrors, bool IncludeTimestamps)
+ bool AllowASTWithErrors, bool IncludeTimestamps,
+ bool ShouldCacheASTInMemory)
: PP(PP), OutputFile(OutputFile), isysroot(isysroot.str()),
SemaPtr(nullptr), Buffer(std::move(Buffer)), Stream(this->Buffer->Data),
Writer(Stream, this->Buffer->Data, ModuleCache, Extensions,
IncludeTimestamps),
- AllowASTWithErrors(AllowASTWithErrors) {
+ AllowASTWithErrors(AllowASTWithErrors),
+ ShouldCacheASTInMemory(ShouldCacheASTInMemory) {
this->Buffer->IsComplete = false;
}
@@ -61,7 +63,8 @@ void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) {
Writer.WriteAST(*SemaPtr, OutputFile, Module, isysroot,
// For serialization we are lenient if the errors were
// only warn-as-error kind.
- PP.getDiagnostics().hasUncompilableErrorOccurred());
+ PP.getDiagnostics().hasUncompilableErrorOccurred(),
+ ShouldCacheASTInMemory);
Buffer->IsComplete = true;
}
OpenPOWER on IntegriCloud