[cfe-dev] Getting the name of a macro passed as an argument to another macro

Phil King phil_king at rocketmail.com
Mon Feb 27 15:33:25 PST 2012


#include <stdbool.h>

#define M(p) p

int f ( void )
   M( true );


then, as expected, I get IntegerLiteral Expr nodes of ( 'int' '1' ) for both lines in the function.

I can get the macro name corresponding to the first '1' (i.e. 'true') by using:

   SL = SM.getSpellingLoc( SM.getImmediateExpansionRange( SL ).first );

   std::pair< FileID, unsigned > ExpansionInfo = SM.getDecomposedLoc( SL );

How do I get the name of the macro passed as the argument to the function-like macro? The code above gives the argument name, 'p'.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120227/e12e39c5/attachment.html>

More information about the cfe-dev mailing list