[cfe-dev] A checker that checks macro calls

Thompson, John John_Thompson at playstation.sony.com
Thu Jun 27 12:04:15 PDT 2013


Todd,

Since you say "when a certain macro is invoked", could this be a case for deriving a class from PPCallbacks which overrides MacroExpands to watch for instances of the macro? You call the Preprocessor's addPPCallbacks function to hook up an instance of your callbacks class.

-John

From: cfe-dev-bounces at cs.uiuc.edu [mailto:cfe-dev-bounces at cs.uiuc.edu] On Behalf Of Todd Nowacki
Sent: Monday, June 24, 2013 3:16 PM
To: cfe-dev at cs.uiuc.edu
Subject: [cfe-dev] A checker that checks macro calls

Hi,

I'm currently trying to implement a checker that needs to know when a certain macro is invoked.

For example, if I had something like:
#define MY_MACRO(x)  ...

I would want to check if the statement is MY_MACRO and then inspect its argument.

I see that with checkPreStmt or checkPostStmt. I can check if it is a macro, via getLocStart and isMacroID. Is there a way to get the name of the macro and it's argument (if it has one)?
I see that MacroInfo could be used to get the args possibly, but it doesn't seem to give me the name.

Thanks!

Sincerely,
Todd Nowacki

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


More information about the cfe-dev mailing list