[cfe-dev] Need help with source-to-source translation

Marcel Schaible via cfe-dev cfe-dev at lists.llvm.org
Tue Aug 1 03:35:20 PDT 2017


Manuel, thanks for your help. Of course I went already through a bunch 
of documentation including libtooling.
My tool is performing now the basic setup and can transform some simple 
cases.

Do you know by chance how to retrieve the ASTContext from a ReturnStmt 
and a FuncDecl?

BTW: Your presentation at the EURO LLVM was very helpful!

Greetings from Munich

Marcel



Am 01.08.2017 um 12:16 schrieb Manuel Klimek:
> You'll probably want to take a look at libtooling:
> https://clang.llvm.org/docs/LibTooling.html
>
> On Fri, Jul 28, 2017 at 4:54 PM Marcel Schaible via cfe-dev 
> <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>> wrote:
>
>     Hi everyone,
>
>     let's consider the example:
>
>     int foo(int p) {
>
>         if ( p)
>
>            /* code path#1 */
>
>     return 0;
>
>          else {
>
>             /* code path#2 */
>
>     return 1;
>
>         }
>
>     }
>
>     1. What is the best solution to get the string representation of
>     the expression of a return statement?
>
>     2. Because I want to perform some transformation with return
>     statements I have to figure out if they are enclosed in a block?
>
>     The example above should be transformed in something like
>
>     int foo(int p) {
>
>         if ( p) { /* <---- */
>
>            /* do some processing ... */
>
>     return 0;
>
>          } /* <--- */
>
>          else {
>
>            /* do some processing ... */
>
>             return 1;
>
>         }
>
>     }
>
>     Any hints or pointers are welcome.
>
>     Thanks
>
>     Marcel
>
>     _______________________________________________
>     cfe-dev mailing list
>     cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>
>     http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>

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


More information about the cfe-dev mailing list