[cfe-dev] A skin to query type details of a given variable

Douglas Gregor dgregor at apple.com
Mon May 9 11:11:00 PDT 2011


On May 9, 2011, at 10:23 AM, Hemendra K wrote:

> Hi,
>  
> I am looking for an API or option that list down details of a variable:
>    - Variable type information
>    - Location of the definition (filename and line number)

libclang is the easiest way to get this information; check out http://clang.llvm.org/doxygen/group__CINDEX.html

You can also get it by adding your own ASTConsumer and looking at the contents of each VarDecl that it sees. That's more involved, though.

>  
> Are there any limitations in using "ast-dump"?

It's an option meant only for debugging, so the format may change from time to time.

> Does it work for all language constructs?

Most, but not all, because it's a debug option.

	- Doug



More information about the cfe-dev mailing list