summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/PCHReader.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-04-14 00:24:19 +0000
committerDouglas Gregor <dgregor@apple.com>2009-04-14 00:24:19 +0000
commit1a0d0b9acc57e0c14ad32008ffac0fea49098121 (patch)
tree374aef8d8ccca117ae326262ca743b283391cb74 /clang/lib/Frontend/PCHReader.cpp
parente4e55d2706a5736e251ec89b1eb68081c18263bb (diff)
downloadbcm5719-llvm-1a0d0b9acc57e0c14ad32008ffac0fea49098121.tar.gz
bcm5719-llvm-1a0d0b9acc57e0c14ad32008ffac0fea49098121.zip
When writing a PCH file, keep track of all of the non-static,
non-inline external definitions (and tentative definitions) that are found at the top level. The corresponding declarations are stored in a record in the PCH file, so that they can be provided to the ASTConsumer (via HandleTopLevelDecl) when the PCH file is read. llvm-svn: 69005
Diffstat (limited to 'clang/lib/Frontend/PCHReader.cpp')
-rw-r--r--clang/lib/Frontend/PCHReader.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp
index 328ed841ce5..f5f6f5d41c9 100644
--- a/clang/lib/Frontend/PCHReader.cpp
+++ b/clang/lib/Frontend/PCHReader.cpp
@@ -12,8 +12,10 @@
//===----------------------------------------------------------------------===//
#include "clang/Frontend/PCHReader.h"
#include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
+#include "clang/AST/DeclGroup.h"
#include "clang/AST/Type.h"
#include "clang/Lex/MacroInfo.h"
#include "clang/Lex/Preprocessor.h"
@@ -663,6 +665,14 @@ PCHReader::PCHReadResult PCHReader::ReadPCHBlock() {
}
#endif
break;
+
+ case pch::EXTERNAL_DEFINITIONS:
+ if (!ExternalDefinitions.empty()) {
+ Error("Duplicate EXTERNAL_DEFINITIONS record in PCH file");
+ return Failure;
+ }
+ ExternalDefinitions.swap(Record);
+ break;
}
}
@@ -1276,6 +1286,17 @@ bool PCHReader::ReadDeclsVisibleInContext(DeclContext *DC,
return false;
}
+void PCHReader::StartTranslationUnit(ASTConsumer *Consumer) {
+ if (!Consumer)
+ return;
+
+ for (unsigned I = 0, N = ExternalDefinitions.size(); I != N; ++I) {
+ Decl *D = GetDecl(ExternalDefinitions[I]);
+ DeclGroupRef DG(D);
+ Consumer->HandleTopLevelDecl(DG);
+ }
+}
+
void PCHReader::PrintStats() {
std::fprintf(stderr, "*** PCH Statistics:\n");
OpenPOWER on IntegriCloud