[cfe-dev] Clang: get list of defined macro

Manuel Klimek klimek at google.com
Tue Oct 30 07:11:01 PDT 2012


On Tue, Oct 30, 2012 at 2:47 PM, GabrieleCocco <cocco at di.unipi.it> wrote:

> Thank you for your answer.
> Unfortunately I haven-t been able to solve it yet. I'm find difficulties to
> find the source location of macro definitions to remove them.
> Moreover, I would like to ask you a question regarding macro expansion and
> AST. In the doxygen I read that "Locations from macros, etc are not
> rewritable.".
> Now, suppose I define a macro like the following:
>
> #define this_opencl_device(p, d) call_this_opencl_device(p, d);
>
> where call_this_opencl_device is a stub function only used to mark the code
> for analysis. After the analysis I would like to remove this call and
> produce a "cleaned" source.
> Unfortunately, the rewriter buffer doesn't contain the expanded macro (i.e.
> the call) but the macro name itself. Therefore I'm not able to remove it
> from the rewriter buffer (I tried).
>
> Any suggestion to walk around this problem?
>

Without seeing your code, I'll not be able to help.

As far as I understand, the rewriter allows you to do textual replacements.
Thus, you'll be able to remove macro calls - you'll "just" need to figure
out where they are on the text level.


Cheers,
/Manuel


>
>
>
> --
> View this message in context:
> http://clang-developers.42468.n3.nabble.com/Clang-get-list-of-defined-macro-tp4027815p4027838.html
> Sent from the Clang Developers mailing list archive at Nabble.com.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121030/d3b20681/attachment.html>


More information about the cfe-dev mailing list