[cfe-commits] r69656 - in /cfe/trunk: include/clang/Lex/PPCallbacks.h lib/Lex/PPDirectives.cpp

Chris Lattner sabre at nondot.org
Mon Apr 20 20:42:12 PDT 2009


Author: lattner
Date: Mon Apr 20 22:42:09 2009
New Revision: 69656

URL: http://llvm.org/viewvc/llvm-project?rev=69656&view=rev
Log:
add a preprocessor callback function for #undef, patch by
Alexei Svitkine!

Modified:
    cfe/trunk/include/clang/Lex/PPCallbacks.h
    cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Lex/PPCallbacks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PPCallbacks.h?rev=69656&r1=69655&r2=69656&view=diff

==============================================================================
--- cfe/trunk/include/clang/Lex/PPCallbacks.h (original)
+++ cfe/trunk/include/clang/Lex/PPCallbacks.h Mon Apr 20 22:42:09 2009
@@ -64,6 +64,11 @@
   /// 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

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=69656&r1=69655&r2=69656&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Mon Apr 20 22:42:09 2009
@@ -1466,7 +1466,11 @@
 
   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);





More information about the cfe-commits mailing list