[cfe-commits] r136885 - in /cfe/trunk/lib/Serialization: ASTReader.cpp ASTWriter.cpp
Douglas Gregor
dgregor at apple.com
Thu Aug 4 10:06:18 PDT 2011
Author: dgregor
Date: Thu Aug 4 12:06:18 2011
New Revision: 136885
URL: http://llvm.org/viewvc/llvm-project?rev=136885&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=136885&r1=136884&r2=136885&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Aug 4 12:06:18 2011
@@ -1568,7 +1568,7 @@
switch (RecType) {
case PPD_MACRO_EXPANSION: {
PreprocessedEntityID GlobalID = getGlobalPreprocessedEntityID(F, Record[0]);
- if (PreprocessedEntity *PE = PPRec.getLoadedPreprocessedEntity(GlobalID))
+ if (PreprocessedEntity *PE = PPRec.getLoadedPreprocessedEntity(GlobalID-1))
return PE;
MacroExpansion *ME =
@@ -1576,13 +1576,13 @@
SourceRange(ReadSourceLocation(F, Record[1]),
ReadSourceLocation(F, Record[2])),
getLocalMacroDefinition(F, Record[4]));
- PPRec.setLoadedPreallocatedEntity(GlobalID, ME);
+ PPRec.setLoadedPreallocatedEntity(GlobalID - 1, ME);
return ME;
}
case PPD_MACRO_DEFINITION: {
PreprocessedEntityID GlobalID = getGlobalPreprocessedEntityID(F, Record[0]);
- if (PreprocessedEntity *PE = PPRec.getLoadedPreprocessedEntity(GlobalID))
+ if (PreprocessedEntity *PE = PPRec.getLoadedPreprocessedEntity(GlobalID-1))
return PE;
unsigned MacroDefID = getGlobalMacroDefinitionID(F, Record[1]);
@@ -1602,7 +1602,7 @@
ReadSourceLocation(F, Record[2]),
ReadSourceLocation(F, Record[3])));
- PPRec.setLoadedPreallocatedEntity(GlobalID, MD);
+ PPRec.setLoadedPreallocatedEntity(GlobalID - 1, MD);
MacroDefinitionsLoaded[MacroDefID - 1] = MD;
if (DeserializationListener)
@@ -1614,7 +1614,7 @@
case PPD_INCLUSION_DIRECTIVE: {
PreprocessedEntityID GlobalID = getGlobalPreprocessedEntityID(F, Record[0]);
- if (PreprocessedEntity *PE = PPRec.getLoadedPreprocessedEntity(GlobalID))
+ if (PreprocessedEntity *PE = PPRec.getLoadedPreprocessedEntity(GlobalID-1))
return PE;
const char *FullFileNameStart = BlobStart + Record[3];
@@ -1632,7 +1632,7 @@
File,
SourceRange(ReadSourceLocation(F, Record[1]),
ReadSourceLocation(F, Record[2])));
- PPRec.setLoadedPreallocatedEntity(GlobalID, ID);
+ PPRec.setLoadedPreallocatedEntity(GlobalID - 1, ID);
return ID;
}
}
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=136885&r1=136884&r2=136885&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Thu Aug 4 12:06:18 2011
@@ -1797,11 +1797,13 @@
}
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 @@
} 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 @@
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 @@
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());
More information about the cfe-commits
mailing list