A skin to query type details of a given variable

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)

Are there any limitations in using “ast-dump”? Does it work for all language constructs?

Regards
-Hemendra

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