add a preprocessor callback function for #undef, patch by

Alexei Svitkine!

llvm-svn: 69656
This commit is contained in:
Chris Lattner 2009-04-21 03:42:09 +00:00
parent 0ec0537403
commit cd6d4b105a
2 changed files with 10 additions and 1 deletions

View File

@ -64,6 +64,11 @@ public:
/// MacroDefined - This hook is called whenever a macro definition is seen.
virtual void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI) {
}
/// MacroUndefined - This hook is called whenever a macro #undef is seen.
/// MI is released immediately following this callback.
virtual void MacroUndefined(const IdentifierInfo *II, const MacroInfo *MI) {
}
};
} // end namespace clang

View File

@ -1466,7 +1466,11 @@ void Preprocessor::HandleUndefDirective(Token &UndefTok) {
if (!MI->isUsed())
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.getIdentifierInfo(), MI);
// Free macro definition.
ReleaseMacroInfo(MI);
setMacroInfo(MacroNameTok.getIdentifierInfo(), 0);