From 2f555fc41552c2ffb5d5163e16c512afaeddf4a6 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 4 Aug 2011 18:56:47 +0000 Subject: Introduce local -> global mapping for preprocessed entity IDs. This is the last of the ID/offset/index mappings that I know of. Unfortunately, the "gap" method of testing doesn't work here due to the way the preprocessing record performs iteration. We'll do more testing once multi-AST loading is possible. llvm-svn: 136902 --- clang/lib/Serialization/ASTWriter.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'clang/lib/Serialization/ASTWriter.cpp') diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 8d2fb9b2b77..f23a0cdce9a 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -1796,8 +1796,10 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) { InclusionAbbrev = Stream.EmitAbbrev(Abbrev); } - unsigned IndexBase = Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0; - unsigned NextPreprocessorEntityID = IndexBase + 1; + unsigned FirstPreprocessorEntityID + = (Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0) + + NUM_PREDEF_PP_ENTITY_IDS; + unsigned NextPreprocessorEntityID = FirstPreprocessorEntityID; RecordData Record; uint64_t BitsInChain = Chain? Chain->TotalModulesSizeInBits : 0; for (PreprocessingRecord::iterator E = PPRec.begin(Chain), @@ -1879,6 +1881,7 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) { BitCodeAbbrev *Abbrev = new BitCodeAbbrev(); Abbrev->Add(BitCodeAbbrevOp(MACRO_DEFINITION_OFFSETS)); Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // # of records + Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // first pp entity Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // # of macro defs Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // first macro def Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); @@ -1887,6 +1890,7 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) { Record.clear(); Record.push_back(MACRO_DEFINITION_OFFSETS); Record.push_back(NumPreprocessingRecords); + Record.push_back(FirstPreprocessorEntityID - NUM_PREDEF_PP_ENTITY_IDS); Record.push_back(MacroDefinitionOffsets.size()); Record.push_back(FirstMacroID - NUM_PREDEF_MACRO_IDS); Stream.EmitRecordWithBlob(MacroDefOffsetAbbrev, Record, -- cgit v1.2.3