summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/ASTUnit.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-06-11 00:36:55 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-06-11 00:36:55 +0000
commitf0168de936ec39f043a801f474fd063e533827ed (patch)
tree25b1446714c56dbbb4e2112f38d04d840b7c6bdd /clang/lib/Frontend/ASTUnit.cpp
parent97fe23e00a88957494bf2c993c998907b894206a (diff)
downloadbcm5719-llvm-f0168de936ec39f043a801f474fd063e533827ed.tar.gz
bcm5719-llvm-f0168de936ec39f043a801f474fd063e533827ed.zip
[libclang] Allow building a precompiled preamble with compiler errors
A while ago we allowed libclang to build a PCH that had compiler errors; this was to retain the performance afforded by a PCH even if the user's code is in an intermediate state. Extend this for the precompiled preamble as well. rdar://14109828 llvm-svn: 183717
Diffstat (limited to 'clang/lib/Frontend/ASTUnit.cpp')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 2d916536d3d..b03e71ccbbd 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -974,8 +974,8 @@ class PrecompilePreambleConsumer : public PCHGenerator {
public:
PrecompilePreambleConsumer(ASTUnit &Unit, const Preprocessor &PP,
StringRef isysroot, raw_ostream *Out)
- : PCHGenerator(PP, "", 0, isysroot, Out), Unit(Unit),
- Hash(Unit.getCurrentTopLevelHashValue()) {
+ : PCHGenerator(PP, "", 0, isysroot, Out, /*AllowASTWithErrors=*/true),
+ Unit(Unit), Hash(Unit.getCurrentTopLevelHashValue()) {
Hash = 0;
}
@@ -996,7 +996,7 @@ public:
virtual void HandleTranslationUnit(ASTContext &Ctx) {
PCHGenerator::HandleTranslationUnit(Ctx);
- if (!Unit.getDiagnostics().hasErrorOccurred()) {
+ if (hasEmittedPCH()) {
// Translate the top-level declarations we captured during
// parsing into declaration IDs in the precompiled
// preamble. This will allow us to deserialize those top-level
@@ -1010,9 +1010,11 @@ public:
class PrecompilePreambleAction : public ASTFrontendAction {
ASTUnit &Unit;
+ PrecompilePreambleConsumer *PreambleConsumer;
public:
- explicit PrecompilePreambleAction(ASTUnit &Unit) : Unit(Unit) {}
+ explicit PrecompilePreambleAction(ASTUnit &Unit)
+ : Unit(Unit), PreambleConsumer(0) {}
virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) {
@@ -1029,10 +1031,16 @@ public:
CI.getPreprocessor().addPPCallbacks(
new MacroDefinitionTrackerPPCallbacks(Unit.getCurrentTopLevelHashValue()));
- return new PrecompilePreambleConsumer(Unit, CI.getPreprocessor(), Sysroot,
- OS);
+ PreambleConsumer = new PrecompilePreambleConsumer(Unit,CI.getPreprocessor(),
+ Sysroot, OS);
+ return PreambleConsumer;
}
+ bool hasEmittedPreamblePCH() const {
+ return PreambleConsumer && PreambleConsumer->hasEmittedPCH();
+ }
+ virtual bool shouldEraseOutputFiles() { return !hasEmittedPreamblePCH(); }
+
virtual bool hasCodeCompletionSupport() const { return false; }
virtual bool hasASTFileSupport() const { return false; }
virtual TranslationUnitKind getTranslationUnitKind() { return TU_Prefix; }
@@ -1622,7 +1630,7 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble(
Act->Execute();
Act->EndSourceFile();
- if (Diagnostics->hasErrorOccurred()) {
+ if (!Act->hasEmittedPreamblePCH()) {
// There were errors parsing the preamble, so no precompiled header was
// generated. Forget that we even tried.
// FIXME: Should we leave a note for ourselves to try again?
OpenPOWER on IntegriCloud