aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Frontend/PCHWriter.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/PCHWriter.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/PCHWriter.h')
-rw-r--r--include/clang/Frontend/PCHWriter.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/clang/Frontend/PCHWriter.h b/include/clang/Frontend/PCHWriter.h
index c05e2436bc..df733b6cae 100644
--- a/include/clang/Frontend/PCHWriter.h
+++ b/include/clang/Frontend/PCHWriter.h
@@ -33,6 +33,7 @@ namespace clang {
class ASTContext;
class LabelStmt;
+class MacroDefinition;
class MemorizeStatCalls;
class Preprocessor;
class Sema;
@@ -160,6 +161,14 @@ private:
/// defined.
llvm::DenseMap<const IdentifierInfo *, uint64_t> MacroOffsets;
+ /// \brief Mapping from macro definitions (as they occur in the preprocessing
+ /// record) to the index into the macro definitions table.
+ llvm::DenseMap<const MacroDefinition *, pch::IdentID> MacroDefinitions;
+
+ /// \brief Mapping from the macro definition indices in \c MacroDefinitions
+ /// to the corresponding offsets within the preprocessor block.
+ std::vector<uint32_t> MacroDefinitionOffsets;
+
/// \brief Declarations encountered that might be external
/// definitions.
///
@@ -272,6 +281,10 @@ public:
return MacroOffsets[II];
}
+ /// \brief Retrieve the ID number corresponding to the given macro
+ /// definition.
+ pch::IdentID getMacroDefinitionID(MacroDefinition *MD);
+
/// \brief Emit a reference to a type.
void AddTypeRef(QualType T, RecordData &Record);