/// setMacroInfo - Specify a macro for this identifier.
///
- void setMacroInfo(IdentifierInfo *II, MacroInfo *MI);
+ void setMacroInfo(IdentifierInfo *II, MacroInfo *MI,
+ bool LoadedFromAST = false);
/// macro_iterator/macro_begin/macro_end - This allows you to walk the current
/// state of the macro table. This visits every currently-defined macro.
/// setMacroInfo - Specify a macro for this identifier.
///
-void Preprocessor::setMacroInfo(IdentifierInfo *II, MacroInfo *MI) {
+void Preprocessor::setMacroInfo(IdentifierInfo *II, MacroInfo *MI,
+ bool LoadedFromAST) {
if (MI) {
Macros[II] = MI;
II->setHasMacroDefinition(true);
- if (II->isFromAST())
+ if (II->isFromAST() && !LoadedFromAST)
II->setChangedSinceDeserialization();
} else if (II->hasMacroDefinition()) {
Macros.erase(II);
II->setHasMacroDefinition(false);
- if (II->isFromAST())
+ if (II->isFromAST() && !LoadedFromAST)
II->setChangedSinceDeserialization();
}
}
return;
}
- if (IdentifierInfo *II = Name.getAsIdentifierInfo())
- if (II->isFromAST())
- II->setChangedSinceDeserialization();
-
// General case: insert the declaration at the appropriate point in the
// list, which already has at least two elements.
IdDeclInfo *IDI = toIdDeclInfo(Ptr);
bool IdentifierResolver::tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name){
if (IdentifierInfo *II = Name.getAsIdentifierInfo())
- updatingIdentifier(*II);
+ readingIdentifier(*II);
void *Ptr = Name.getFETokenInfo<void>();
// For uninteresting identifiers, just build the IdentifierInfo
// and associate it with the persistent ID.
IdentifierInfo *II = KnownII;
- if (!II)
+ if (!II) {
II = &Reader.getIdentifierTable().getOwn(StringRef(k.first, k.second));
+ KnownII = II;
+ }
Reader.SetIdentifierInfo(ID, II);
II->setIsFromAST();
Reader.markIdentifierUpToDate(II);
// Build the IdentifierInfo itself and link the identifier ID with
// the new IdentifierInfo.
IdentifierInfo *II = KnownII;
- if (!II)
+ if (!II) {
II = &Reader.getIdentifierTable().getOwn(StringRef(k.first, k.second));
+ KnownII = II;
+ }
Reader.markIdentifierUpToDate(II);
II->setIsFromAST();
}
// Finally, install the macro.
- PP.setMacroInfo(II, MI);
+ PP.setMacroInfo(II, MI, /*LoadedFromAST=*/true);
// Remember that we saw this macro last so that we add the tokens that
// form its body to it.
}
void ASTReader::LoadMacroDefinition(
- llvm::DenseMap<IdentifierInfo *, uint64_t>::iterator Pos) {
+ llvm::DenseMap<IdentifierInfo *, uint64_t>::iterator Pos) {
assert(Pos != UnreadMacroRecordOffsets.end() && "Unknown macro definition");
uint64_t Offset = Pos->second;
UnreadMacroRecordOffsets.erase(Pos);
if (!IdTable)
return false;
+ ASTIdentifierLookupTrait Trait(IdTable->getInfoObj().getReader(),
+ M, This->Found);
+
std::pair<const char*, unsigned> Key(This->Name.begin(),
This->Name.size());
- ASTIdentifierLookupTable::iterator Pos = IdTable->find(Key);
+ ASTIdentifierLookupTable::iterator Pos = IdTable->find(Key, &Trait);
if (Pos == IdTable->end())
return false;