// Okay, we finally have a valid identifier to undef.
MacroInfo *MI = getMacroInfo(MacroNameTok.getIdentifierInfo());
+ // If the callbacks want to know, tell them about the macro #undef.
+ // Note: no matter if the macro was defined or not.
+ if (Callbacks)
+ Callbacks->MacroUndefined(MacroNameTok, MI);
+
// If the macro is not defined, this is a noop undef, just return.
if (MI == 0) return;
if (!MI->isUsed() && MI->isWarnIfUnused())
Diag(MI->getDefinitionLoc(), diag::pp_macro_not_used);
- // If the callbacks want to know, tell them about the macro #undef.
- if (Callbacks)
- Callbacks->MacroUndefined(MacroNameTok, MI);
-
if (MI->isWarnIfUnused())
WarnUnusedMacroLocs.erase(MI->getDefinitionLoc());
void PreprocessingRecord::MacroUndefined(const Token &Id,
const MacroInfo *MI) {
- MacroDefinitions.erase(MI);
+ // Note: MI may be null (when #undef'ining an undefined macro).
+ if (MI)
+ MacroDefinitions.erase(MI);
}
void PreprocessingRecord::InclusionDirective(