summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/ASTUnit.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-09-24 23:29:12 +0000
committerDouglas Gregor <dgregor@apple.com>2010-09-24 23:29:12 +0000
commit2fb99df2c3a3b5d12dfb3781ff16df8c15c782a5 (patch)
tree32f95c8281277e3b86ca87e61cc33d8f039bac46 /clang/lib/Frontend/ASTUnit.cpp
parent5573fde3426c91332afcd4180193e14cc0a01c32 (diff)
downloadbcm5719-llvm-2fb99df2c3a3b5d12dfb3781ff16df8c15c782a5.tar.gz
bcm5719-llvm-2fb99df2c3a3b5d12dfb3781ff16df8c15c782a5.zip
When setting the globally-visible declarations for a particular
identifier, we may have a Sema object but no translation unit scope (because parsing is finished). In this case, we still need to update the IdResolver, which might still be used when writing a PCH containing another PCH (without chaining). This bug manifested as a failure with precompiled preambles. Also, add a little environment-variable-sensitive logging for libclang. llvm-svn: 114774
Diffstat (limited to 'clang/lib/Frontend/ASTUnit.cpp')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index bd7e712bc78..b81f89390d8 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -749,9 +749,20 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) {
getSourceManager());
StoredDiagnostics[I].setLocation(Loc);
}
+
+ if (getenv("LIBCLANG_LOGGING"))
+ fprintf(stderr, "libclang: using precompiled preamble for \"%s\" at "
+ "\"%s\"\n",
+ OriginalSourceFile.c_str(),
+ PreambleFile.c_str());
+
} else {
PreprocessorOpts.PrecompiledPreambleBytes.first = 0;
PreprocessorOpts.PrecompiledPreambleBytes.second = false;
+
+ if (getenv("LIBCLANG_LOGGING"))
+ fprintf(stderr, "libclang: not using precompiled preamble for \"%s\"\n",
+ OriginalSourceFile.c_str());
}
llvm::OwningPtr<TopLevelDeclTrackerAction> Act;
@@ -1215,6 +1226,13 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble(
// Create the source manager.
Clang.setSourceManager(new SourceManager(getDiagnostics()));
+ if (getenv("LIBCLANG_LOGGING"))
+ fprintf(stderr, "libclang: creating precompiled preamble for \"%s\" at "
+ "\"%s\" (%u bytes)\n",
+ OriginalSourceFile.c_str(),
+ PreamblePCHPath.c_str(),
+ (unsigned)Preamble.size());
+
llvm::OwningPtr<PrecompilePreambleAction> Act;
Act.reset(new PrecompilePreambleAction(*this));
if (!Act->BeginSourceFile(Clang, Clang.getFrontendOpts().Inputs[0].second,
@@ -1229,6 +1247,11 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble(
PreambleRebuildCounter = DefaultPreambleRebuildInterval;
PreprocessorOpts.eraseRemappedFile(
PreprocessorOpts.remapped_file_buffer_end() - 1);
+
+ if (getenv("LIBCLANG_LOGGING"))
+ fprintf(stderr, "libclang: precompiled preamble compilation for \"%s\" "
+ "failed\n", OriginalSourceFile.c_str());
+
return 0;
}
@@ -1239,7 +1262,10 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble(
if (Diagnostics->hasErrorOccurred()) {
// 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?
+
+ if (getenv("LIBCLANG_LOGGING"))
+ fprintf(stderr, "libclang: precompiled preamble compilation for \"%s\" "
+ "failed\n", OriginalSourceFile.c_str());
llvm::sys::Path(FrontendOpts.OutputFile).eraseFromDisk();
Preamble.clear();
if (CreatedPreambleBuffer)
@@ -1278,7 +1304,11 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble(
if (PreambleTimer)
PreambleTimer->stopTimer();
-
+
+ if (getenv("LIBCLANG_LOGGING"))
+ fprintf(stderr, "libclang: precompiled preamble for \"%s\" completed\n",
+ OriginalSourceFile.c_str());
+
PreambleRebuildCounter = 1;
PreprocessorOpts.eraseRemappedFile(
PreprocessorOpts.remapped_file_buffer_end() - 1);
OpenPOWER on IntegriCloud