aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Frontend/PCHReader.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-03-19 21:51:54 +0000
committerDouglas Gregor <dgregor@apple.com>2010-03-19 21:51:54 +0000
commit6a5a23f8e7fb65e028c8092bc1d1a1d9dfe2e9bc (patch)
treeca3c65a123fff4e56a3b6d2090f716334c63aade /include/clang/Frontend/PCHReader.h
parent8d52cbdce856d6498a5c454b8e113498e645cc4d (diff)
Implement serialization and lazy deserialization of the preprocessing
record (which includes all macro instantiations and definitions). As with all lay deserialization, this introduces a new external source (here, an external preprocessing record source) that loads all of the preprocessed entities prior to iterating over the entities. The preprocessing record is an optional part of the precompiled header that is disabled by default (enabled with -detailed-preprocessing-record). When the preprocessor given to the PCH writer has a preprocessing record, that record is written into the PCH file. When the PCH reader is given a PCH file that contains a preprocessing record, it will be lazily loaded (which, effectively, implicitly adds -detailed-preprocessing-record). This is the first case where we have sections of the precompiled header that are added/removed based on a compilation flag, which is unfortunate. However, this data consumes ~550k in the PCH file for Cocoa.h (out of ~9.9MB), and there is a non-trivial cost to gathering this detailed preprocessing information, so it's too expensive to turn on by default. In the future, we should investigate a better encoding of this information. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99002 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Frontend/PCHReader.h')
-rw-r--r--include/clang/Frontend/PCHReader.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/include/clang/Frontend/PCHReader.h b/include/clang/Frontend/PCHReader.h
index e4fd1a2b15..9ccd382dba 100644
--- a/include/clang/Frontend/PCHReader.h
+++ b/include/clang/Frontend/PCHReader.h
@@ -21,6 +21,7 @@
#include "clang/AST/Type.h"
#include "clang/AST/TemplateBase.h"
#include "clang/Lex/ExternalPreprocessorSource.h"
+#include "clang/Lex/PreprocessingRecord.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/SourceManager.h"
@@ -53,6 +54,7 @@ class Decl;
class DeclContext;
class GotoStmt;
class LabelStmt;
+class MacroDefinition;
class NamedDecl;
class Preprocessor;
class Sema;
@@ -151,6 +153,7 @@ private:
/// actually required will be de-serialized.
class PCHReader
: public ExternalPreprocessorSource,
+ public ExternalPreprocessingRecordSource,
public ExternalSemaSource,
public IdentifierInfoLookup,
public ExternalIdentifierLookup,
@@ -296,6 +299,17 @@ private:
/// been loaded.
llvm::SmallVector<Selector, 16> SelectorsLoaded;
+ /// \brief Offsets of all of the macro definitions in the preprocessing
+ /// record in the PCH file.
+ const uint32_t *MacroDefinitionOffsets;
+
+ /// \brief The macro definitions we have already loaded.
+ llvm::SmallVector<MacroDefinition *, 16> MacroDefinitionsLoaded;
+
+ /// \brief The number of preallocated preprocessing entities in the
+ /// preprocessing record.
+ unsigned NumPreallocatedPreprocessingEntities;
+
/// \brief A sorted array of source ranges containing comments.
SourceRange *Comments;
@@ -527,9 +541,7 @@ public:
}
/// \brief Set the Preprocessor to use.
- void setPreprocessor(Preprocessor &pp) {
- PP = &pp;
- }
+ void setPreprocessor(Preprocessor &pp);
/// \brief Sets and initializes the given Context.
void InitializeContext(ASTContext &Context);
@@ -550,6 +562,9 @@ public:
/// which contains a (typically-empty) subset of the predefines
/// build prior to including the precompiled header.
const std::string &getSuggestedPredefines() { return SuggestedPredefines; }
+
+ /// \brief Read preprocessed entities into the
+ virtual void ReadPreprocessedEntities();
/// \brief Reads the source ranges that correspond to comments from
/// an external AST source.
@@ -727,6 +742,9 @@ public:
/// \brief Read the set of macros defined by this external macro source.
virtual void ReadDefinedMacros();
+ /// \brief Retrieve the macro definition with the given ID.
+ MacroDefinition *getMacroDefinition(pch::IdentID ID);
+
/// \brief Retrieve the AST context that this PCH reader
/// supplements.
ASTContext *getContext() { return Context; }