aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/PCHWriter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-10 18:08:30 +0000
committerChris Lattner <sabre@nondot.org>2009-04-10 18:08:30 +0000
commitdf961c28f84666051ad59d2da1f44023f6366d02 (patch)
tree008905b0e38cac3473b3813a64ac716d2c570230 /lib/Frontend/PCHWriter.cpp
parent7c5d24efcd2e505b5739f7def08dfe25ce59a1b2 (diff)
emit tokens, constify the Preprocessor passed down into PCH writer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68798 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PCHWriter.cpp')
-rw-r--r--lib/Frontend/PCHWriter.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index 05447dcd6a..255ce8bf8d 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -479,7 +479,7 @@ void PCHWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
/// \brief Writes the block containing the serialized form of the
/// preprocessor.
///
-void PCHWriter::WritePreprocessor(Preprocessor &PP) {
+void PCHWriter::WritePreprocessor(const Preprocessor &PP) {
// Enter the preprocessor block.
S.EnterSubblock(pch::PREPROCESSOR_BLOCK_ID, 3);
@@ -527,7 +527,29 @@ void PCHWriter::WritePreprocessor(Preprocessor &PP) {
S.EmitRecord(Code, Record);
Record.clear();
- // FIXME: Emit the tokens array.
+ // Emit the tokens array.
+ for (unsigned TokNo = 0, e = MI->getNumTokens(); TokNo != e; ++TokNo) {
+ // Note that we know that the preprocessor does not have any annotation
+ // tokens in it because they are created by the parser, and thus can't be
+ // in a macro definition.
+ const Token &Tok = MI->getReplacementToken(TokNo);
+
+ Record.push_back(Tok.getLocation().getRawEncoding());
+ Record.push_back(Tok.getLength());
+
+ // FIXME: Output the identifier Info ID #!
+ // FIXME: When reading literal tokens, reconstruct the literal pointer if
+ // it is needed.
+ Record.push_back((intptr_t)Tok.getIdentifierInfo());
+
+ // FIXME: Should translate token kind to a stable encoding.
+ Record.push_back(Tok.getKind());
+ // FIXME: Should translate token flags to a stable encoding.
+ Record.push_back(Tok.getFlags());
+
+ S.EmitRecord(pch::PP_TOKEN, Record);
+ Record.clear();
+ }
}
@@ -719,7 +741,7 @@ void PCHWriter::WriteDeclsBlock(ASTContext &Context) {
PCHWriter::PCHWriter(llvm::BitstreamWriter &S)
: S(S), NextTypeID(pch::NUM_PREDEF_TYPE_IDS) { }
-void PCHWriter::WritePCH(ASTContext &Context, Preprocessor &PP) {
+void PCHWriter::WritePCH(ASTContext &Context, const Preprocessor &PP) {
// Emit the file header.
S.Emit((unsigned)'C', 8);
S.Emit((unsigned)'P', 8);