[cfe-dev] pragmas, source-to-source

Cedomir Segulja cedomir.segulja at gmail.com
Fri Jan 23 09:30:28 PST 2009


Hi all,

I've just started using clang. I would like to use it for source-to-source
transformations. For start, I would like to do the following:
If a #pragma <some_name> precedes a function call, then change the name of
the function to be called. For example:

input:
...
#pragma <...>
my_func(...)
...

output:
...
my_function_NEW(...)
...

I've been looking at the objC->C example and I understand (to limited extent
tho, how to use Rewriter class to modify the input file). Also, I've
familiarize myself with HandlePragma mechanism, and I am able to indentify
that there is a #pragma <...> in the code.

The thing that I don't know is how to pass the information from
lexical/syntax anlysis to the ASTConsumer, i.e how do I say (in this
example) that specific call to my_func() should be renamed? Should I use
SourceLocation or there is a better way?

Thanks.

Cedomir.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090123/3c533042/attachment.html>


More information about the cfe-dev mailing list