[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-dev
Subject:    [cfe-dev] AST manipulation from 2 cpp files
From:       Andrey Tarasevich <tarasevich () cs ! uni-saarland ! de>
Date:       2012-11-29 14:16:20
Message-ID: 8CCD62E7-A0E6-43ED-815D-4284DE2D6D1E () cs ! uni-saarland ! de
[Download RAW message or body]

Hi!

I'm using clang for some source-to-source transformations of the arbitrary C code. \
Until now it was pretty enough for me to use rewriter API for such transformation, \
but now I want to perform manipulations on AST directly, i.e. I want to take AST node \
from one source file and insert it into another. For instance I want to copy some \
arbitrary for-loop from file test_1.cpp, then resolve all the variable and type \
conflicts and insert that loop into another AST in file test_2.cpp. 

I'm aware, that there is no AST copy mechanism in clang, but I can implement it on \
top of TreeTransform class, which will give me flexibility to some degree. At this \
point I have only one problem - how to use AST from different cpp files in one \
context? As far as I know for each compiler instance and thus cpp file there is \
separate ASTContext and AST node can't be used outside its context. 

To sum it up - how can I use AST node from one source file in context of another cpp \
file, i.e. in another ASTContext? Is it possible? Is there any workarounds?

Thanks in advance,
Andrey Tarasevich
_______________________________________________
cfe-dev mailing list
cfe-dev@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic