[cfe-dev] lookup from AST

Axel Naumann Axel.Naumann at cern.ch
Wed Oct 14 07:09:49 PDT 2009


Hi,

the consumer is great when I want to create a map / copy of the AST 
data. But I really would like to keep the AST data inside the 
ASTContext, and only query it, e.g. starting form a type name. If I 
understand the cunsumer correctly I would have to consume the AST and 
then walk my way down the scopes, for every lookup - even though that's 
already (much better :-) implemented in Sema...

Cheers, Axel.


steve naroff wrote on 10/13/2009 07:50 PM:
> Hi Axel,
> 
> Sema is considered a transient object (whose 'output' is a well-formed 
> AST).
> 
> The design is oriented toward creating an ASTConsumer. This 'callback' 
> interface, combined with ASTContext's "get*" functions (and the 
> respective AST's) should do the trick.
> 
> Did you try this? If we are missing some functionality in the AST, let 
> us know (it is entirely possible that there is some logic that needs to 
> move from Sema->AST).
> 
> snaroff
> 
> On Oct 13, 2009, at 9:04 AM, Axel Naumann wrote:
> 
>> Hi,
>>
>> I need to access reflection gathered from some C++ code, e.g. which
>> classes are defined, what data members does class "MyClass" have. My
>> naive approach was to parse the source and query the resulting
>> ASTContext using Sema, i.e. lookup "MyClass" and walk its decls. But
>> Sema is a non-public API, which makes me wonder whether this is the
>> right approach.
>>
>> Is it?
>>
>> Cheers, Axel.
>> _______________________________________________
>> 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