/// \brief Retrieve the macro definition with the given ID.
MacroDefinition *getMacroDefinition(pch::IdentID ID);
- /// \brief Erase the macro that's bound to the given IdentifierInfo.
- void EraseMacro(IdentifierInfo *II);
-
- /// \brief Check if the given macro identifier is built-in.
- bool isBuiltinMacro(IdentifierInfo *II);
-
/// \brief Retrieve the AST context that this PCH reader
/// supplements.
ASTContext *getContext() { return Context; }
uint32_t Offset = ReadUnalignedLE32(d);
Reader.ReadMacroRecord(Stream, Offset);
DataLen -= 4;
- } else if (II->hasMacroDefinition() && !Reader.isBuiltinMacro(II)) {
- // A previous part of the chain added a macro, but this part #undefed it.
- Reader.EraseMacro(II);
}
// Read all of the declarations visible at global scope with this
return MacroDefinitionsLoaded[ID];
}
-void PCHReader::EraseMacro(IdentifierInfo *II) {
- PP->setMacroInfo(II, 0);
-}
-
-bool PCHReader::isBuiltinMacro(IdentifierInfo *II) {
- assert(II->hasMacroDefinition() && "Identifier is not a macro");
- return PP->getMacroInfo(II)->isBuiltinMacro();
-}
-
/// \brief If we are loading a relocatable PCH file, and the filename is
/// not an absolute path, add the system root to the beginning of the file
/// name.
}
IdentifierInfo* PCHReader::get(const char *NameStart, const char *NameEnd) {
- // Try to find this name within our on-disk hash tables. We need to aggregate
- // the info from all of them.
- IdentifierInfo *II = 0;
+ // Try to find this name within our on-disk hash tables. We start with the
+ // most recent one, since that one contains the most up-to-date info.
for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
PCHIdentifierLookupTable *IdTable
- = (PCHIdentifierLookupTable *)Chain[N - I - 1]->IdentifierLookupTable;
+ = (PCHIdentifierLookupTable *)Chain[I]->IdentifierLookupTable;
if (!IdTable)
continue;
std::pair<const char*, unsigned> Key(NameStart, NameEnd - NameStart);
// Dereferencing the iterator has the effect of building the
// IdentifierInfo node and populating it with the various
// declarations it needs.
- II = *Pos;
+ return *Pos;
}
- return II;
+ return 0;
}
std::pair<ObjCMethodList, ObjCMethodList>
for (IdentifierResolver::iterator D = IdentifierResolver::begin(II),
DEnd = IdentifierResolver::end();
D != DEnd; ++D)
- if (!Writer.hasChain() || (*D)->getPCHLevel() == 0)
- DataLen += sizeof(pch::DeclID);
+ DataLen += sizeof(pch::DeclID);
}
clang::io::Emit16(Out, DataLen);
// We emit the key length after the data length so that every
for (llvm::SmallVector<Decl *, 16>::reverse_iterator D = Decls.rbegin(),
DEnd = Decls.rend();
D != DEnd; ++D)
- if (!Writer.hasChain() || (*D)->getPCHLevel() == 0)
- clang::io::Emit32(Out, Writer.getDeclID(*D));
+ clang::io::Emit32(Out, Writer.getDeclID(*D));
}
};
} // end anonymous namespace