[cfe-dev] Getting the pointer to an out-of-class VarDecl

Mihai Draghicioiu mihai.draghicioiu at gmail.com
Sun Sep 28 09:42:07 PDT 2014


Hi guys. I'm trying to get a pointer to the last VarDecl from the first
VarDecl, so I can access the initialization Expr. As you can see below,
There are two VarDecls, and I'd like to get a pointer to the out-of-class
one. Also, I can't figure out how the second VarDecl gets its parent
pointer.

I just hope I don't have to recurse the AST again each time.

class Foo {
	static int poop;};
int Foo::poop = 3;


TranslationUnitDecl 0x4b6b060 <<invalid sloc>> <invalid sloc>
|-TypedefDecl 0x4b6b5a0 <<invalid sloc>> <invalid sloc> implicit
__int128_t '__int128'
|-TypedefDecl 0x4b6b600 <<invalid sloc>> <invalid sloc> implicit
__uint128_t 'unsigned __int128'
|-TypedefDecl 0x4b6b9c0 <<invalid sloc>> <invalid sloc> implicit
__builtin_va_list '__va_list_tag [1]'
|-CXXRecordDecl 0x4b6ba10 </tmp/cxxXX38p7:1:1, line:3:1> line:1:7
class Foo definition
| |-CXXRecordDecl 0x4b6bb20 <col:1, col:7> col:7 implicit class Foo
| `-VarDecl 0x4b6bbc0 <line:2:2, col:13> col:13 poop 'int' static
`-VarDecl 0x4b6bc50 parent 0x4b6ba10 prev 0x4b6bbc0 <line:5:1, col:17>
col:10 poop 'int' cinit
  `-IntegerLiteral 0x4b6bd00 <col:17> 'int' 3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140928/9edc58e0/attachment.html>


More information about the cfe-dev mailing list