diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-14 00:24:19 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-14 00:24:19 +0000 |
commit | fdd0172ca1b3c837f8c2b37d69cc2085234e09fa (patch) | |
tree | e3b58dd5415f44fb1ede881b6518bd2e2e333fe2 /lib/Frontend/PCHReader.cpp | |
parent | ab76d45e023fc5ae966968344e180cd09fdcc746 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69005 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PCHReader.cpp')
-rw-r--r-- | lib/Frontend/PCHReader.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 328ed841ce..f5f6f5d41c 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/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"); |