[cfe-commits] r130402 - /cfe/trunk/lib/Lex/PPMacroExpansion.cpp

Douglas Gregor dgregor at apple.com
Thu Apr 28 09:36:13 PDT 2011


Author: dgregor
Date: Thu Apr 28 11:36:13 2011
New Revision: 130402

URL: http://llvm.org/viewvc/llvm-project?rev=130402&view=rev
Log:
Only call the MacroExpands callback when we're actually going to
expand the macro, based on a patch by Ori Avtalion. Fixes PR9799.

Modified:
    cfe/trunk/lib/Lex/PPMacroExpansion.cpp

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=130402&r1=130401&r2=130402&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Thu Apr 28 11:36:13 2011
@@ -176,8 +176,6 @@
 /// expanded as a macro, handle it and return the next token as 'Identifier'.
 bool Preprocessor::HandleMacroExpandedIdentifier(Token &Identifier,
                                                  MacroInfo *MI) {
-  if (Callbacks) Callbacks->MacroExpands(Identifier, MI);
-
   // If this is a macro expansion in the "#if !defined(x)" line for the file,
   // then the macro could expand to different things in other contexts, we need
   // to disable the optimization in this case.
@@ -185,6 +183,7 @@
 
   // If this is a builtin macro, like __LINE__ or _Pragma, handle it specially.
   if (MI->isBuiltinMacro()) {
+    if (Callbacks) Callbacks->MacroExpands(Identifier, MI);
     ExpandBuiltinMacro(Identifier);
     return false;
   }
@@ -225,6 +224,8 @@
   // Notice that this macro has been used.
   markMacroAsUsed(MI);
 
+  if (Callbacks) Callbacks->MacroExpands(Identifier, MI);
+  
   // If we started lexing a macro, enter the macro expansion body.
 
   // Remember where the token is instantiated.





More information about the cfe-commits mailing list