/// keep a mapping to the history of all macro definitions and #undefs in
/// the reverse order (the latest one is in the head of the list).
llvm::DenseMap<IdentifierInfo*, MacroInfo*> Macros;
-
+ friend class ASTReader;
+
/// \brief Macros that we want to warn because they are not used at the end
/// of the translation unit; we store just their SourceLocations instead
/// something like MacroInfo*. The benefit of this is that when we are
else {
IdentifierInfo *II = Names[I].get<IdentifierInfo *>();
if (!II->hasMacroDefinition()) {
- II->setHasMacroDefinition(true);
- if (DeserializationListener)
- DeserializationListener->MacroVisible(II);
+ // Make sure that this macro hasn't been #undef'd in the mean-time.
+ llvm::DenseMap<IdentifierInfo*, MacroInfo*>::iterator Known
+ = PP.Macros.find(II);
+ if (Known == PP.Macros.end() ||
+ Known->second->getUndefLoc().isInvalid()) {
+ II->setHasMacroDefinition(true);
+ if (DeserializationListener)
+ DeserializationListener->MacroVisible(II);
+ }
}
}
}