diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-08-04 17:06:18 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-08-04 17:06:18 +0000 |
commit | 7338a922dd1164002922163200b18a2c24eb0209 (patch) | |
tree | 81200d5c39393d3d6113e90fc913be06239b1e82 /lib/Serialization/ASTWriter.cpp | |
parent | 837593fec8389eea3143920d7f2180b079b609e8 (diff) |
In the AST reader and writer, slide the preprocessed entity IDs by +1
so that we use ID zero as a sentinel for "no result". This matches the
convention set by all of the other global IDs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136885 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index caf5836efc..8d2fb9b2b7 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -1797,11 +1797,13 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) { } unsigned IndexBase = Chain ? PPRec.getNumLoadedPreprocessedEntities() : 0; + unsigned NextPreprocessorEntityID = IndexBase + 1; RecordData Record; uint64_t BitsInChain = Chain? Chain->TotalModulesSizeInBits : 0; for (PreprocessingRecord::iterator E = PPRec.begin(Chain), EEnd = PPRec.end(Chain); - E != EEnd; ++E) { + E != EEnd; + (void)++E, ++NumPreprocessingRecords, ++NextPreprocessorEntityID) { Record.clear(); if (MacroDefinition *MD = dyn_cast<MacroDefinition>(*E)) { @@ -1826,7 +1828,7 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) { } else MacroDefinitionOffsets.push_back(Stream.GetCurrentBitNo()); - Record.push_back(IndexBase + NumPreprocessingRecords++); + Record.push_back(NextPreprocessorEntityID); Record.push_back(ID); AddSourceLocation(MD->getSourceRange().getBegin(), Record); AddSourceLocation(MD->getSourceRange().getEnd(), Record); @@ -1842,7 +1844,7 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) { BitsInChain + Stream.GetCurrentBitNo()); if (MacroExpansion *ME = dyn_cast<MacroExpansion>(*E)) { - Record.push_back(IndexBase + NumPreprocessingRecords++); + Record.push_back(NextPreprocessorEntityID); AddSourceLocation(ME->getSourceRange().getBegin(), Record); AddSourceLocation(ME->getSourceRange().getEnd(), Record); AddIdentifierRef(ME->getName(), Record); @@ -1853,7 +1855,7 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) { if (InclusionDirective *ID = dyn_cast<InclusionDirective>(*E)) { Record.push_back(PPD_INCLUSION_DIRECTIVE); - Record.push_back(IndexBase + NumPreprocessingRecords++); + Record.push_back(NextPreprocessorEntityID); AddSourceLocation(ID->getSourceRange().getBegin(), Record); AddSourceLocation(ID->getSourceRange().getEnd(), Record); Record.push_back(ID->getFileName().size()); |