<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="Helvetica, Arial, sans-serif">Dear all,<br>
I need to perform code transformations based on inter-procedural
analysis done on multiple translation units. <br>
<br>
In order to do that I need to keep the AST generated for each
translation unit in memory, do my analysis and then restart rewriting
part of the AST I need to modify. Conceptually is not difficult my I am
experiencing a weird behavior of Clang and maybe you can help me. <br>
<br>
basically that's what I am doing:<br>
<br>
vector<ASTContext*> ctxs;<br>
for each input file{<br>
    Preprocessor PP(...);<br>
    InitializePreprocessor(PP);<br>
    ctxs.push_back( new ASTContext(...., false, 0) );<br>
    ParseAST(PP, *ctxs.back(),...);<br>
}<br>
// Now do ANALYSIS (e.g. building a clang::CallGraph )<br>
for each context in ctxs{<br>
    DeclContext *DC=ctxs[i];<br>
    for each decl{<br>
        if decl is a func{<br>
            FuncDecl* FD = ();<br>
            cout << FD->getNameAsString() << endl;
<--- ERROR<br>
        }<br>
    }<br>
}<br>
    <br>
As you can see from the code, every time I try to access the
information of the ASTContext it looks like everything is gone. why?<br>
I have to say that every time I parse a new translation unit I
reinitialize the Preprocessor and I use different SourceManagers. <br>
<br>
I also saw the possibility to use PHC files but I as I already told you
I need to modify portion of the code and I am afraid PHC will not be
suitable for me. <br>
<br>
regards, Simone<br>
<br>
</font>
</body>
</html>