[cfe-dev] Using the clang::SourceManager's after calling clang::ParseAST()

steve naroff snaroff at apple.com
Thu Oct 30 05:00:02 PDT 2008


On Oct 30, 2008, at 7:43 AM, Paolo Bolzoni wrote:

>
> I'd like to use clang's AST for global (i.e., compilation-unit-wide)
> analyses.  Thus, I plan to make a clang::ASTConsumer derived class
> that collects everything I need and finally analyze the data as a
> whole.
>
> After the analysis, in order to produce interesting output messages
> I need to refer to the source files using the clang::SourceLocation.
>
> As far as I understand, the clang::SourceLocation(s) are just integers
> references that only make sense with respect to the  
> clang::SourceManager,
> which is part of the preprocessor I have to make to parse the file and
> obtain the AST.
>
> Now, if I use: clang::ParseAST(&PP, *C, false, false) (overriding the
> FreeMemory default parameter) after completing parsing is it true
> that the clang::SourceManager inside PP will still contains all the
> info about the last parsed compilation unit?
>

Should be fine.

> If so, can I just to keep copies of clang::SourceLocation(s) and use
> them with that source manager?
>

Yes.

snaroff

> pb
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list