[cfe-dev] lookup of a variable

Jan Bierbaum s3306700 at inf.tu-dresden.de
Wed Sep 1 03:08:15 PDT 2010


Hi!


Given the qualified identifier of a variable (as a pure string like
"A::B::foo"), an ASTContext and a Sema how can I

1) verify a variable with the given name exists within the current
translation unit?
2) get its type?
3) the value it was initialized to, if any?

How about the same issue with an unqualified identifier and a
Decl/DeclContext to start the search from?

I found 'Sema::Lookup*Name' and it looks like a good start. But to use
that I need a 'LookupResult' which in turn needs a 'DeclarationNameInfo'
that yet again needs a 'SourceLocation'. And I do not have that but only
an ID...

Can I use these Sema lookups at all? All examples I saw use them from
within other Sema methods.


Any hint/help appreciated :-)



Regards, Jan.



More information about the cfe-dev mailing list