]> granicus.if.org Git - clang/commitdiff
add a ppcallback hook for macro definitions.
authorChris Lattner <sabre@nondot.org>
Sun, 12 Apr 2009 01:39:54 +0000 (01:39 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 12 Apr 2009 01:39:54 +0000 (01:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68883 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/PPCallbacks.h
lib/Lex/PPDirectives.cpp

index cd7c5e42156f07f977d73b57d700d402ee44fd7d..d2e3f353cbfd3d8ed27361f296ffd0300faabf7a 100644 (file)
@@ -55,10 +55,15 @@ public:
                              const std::string &Str) {
   }
   
-  /// MacroExpands - This is called Preprocessor::HandleMacroExpandedIdentifier
-  /// when a macro invocation is found.
+  /// MacroExpands - This is called by
+  /// Preprocessor::HandleMacroExpandedIdentifier when a macro invocation is
+  /// found.
   virtual void MacroExpands(const Token &Id, const MacroInfo* MI) {
   }
+  
+  /// MacroDefined - This hook is called whenever a macro definition is seen.
+  virtual void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI) {
+  }
 };
 
 }  // end namespace clang
index ba321a7f6730c5f7d717a76afd4e3132e00ebb32..52f673c6d3a3f0cb3a33fab59655a04ec0bf969f 100644 (file)
@@ -1402,6 +1402,10 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) {
   }
   
   setMacroInfo(MacroNameTok.getIdentifierInfo(), MI);
+  
+  // If the callbacks want to know, tell them about the macro definition.
+  if (Callbacks)
+    Callbacks->MacroDefined(MacroNameTok.getIdentifierInfo(), MI);
 }
 
 /// HandleUndefDirective - Implements #undef.