<div dir="ltr">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.<div><br></div><div>I just hope I don't have to recurse the AST again each time.<br><div><br></div><div><pre style="color:rgb(0,0,0);font-size:medium"><span style="color:rgb(128,0,0);font-weight:bold">class</span> Foo <span style="color:rgb(128,0,128)">{</span>
<span style="color:rgb(128,0,0);font-weight:bold">static</span> <span style="color:rgb(128,0,0);font-weight:bold">int</span> poop<span style="color:rgb(128,0,128)">;</span>
<span style="color:rgb(128,0,128)">}</span><span style="color:rgb(128,0,128)">;</span>
<span style="color:rgb(128,0,0);font-weight:bold">int</span> Foo<span style="color:rgb(128,0,128)">::</span>poop <span style="color:rgb(128,128,48)">=</span> <span style="color:rgb(0,140,0)">3</span><span style="color:rgb(128,0,128)">;</span></pre></div><div><br></div><div><pre style="color:white;background:black"><span style="background-color:rgb(0,0,0)"><span style="color:lime">TranslationUnitDecl</span><span style="color:olive"> 0x4b6b060</span><span style="color:white"> <</span><span style="color:olive"><invalid sloc></span><span style="color:white">> </span><span style="color:olive"><invalid sloc></span><span style="color:white"> <br></span><span style="color:navy">|-</span><span style="color:lime">TypedefDecl</span><span style="color:olive"> 0x4b6b5a0</span><span style="color:white"> <</span><span style="color:olive"><invalid sloc></span><span style="color:white">> </span><span style="color:olive"><invalid sloc></span><span style="color:white"> implicit</span><span style="color:aqua"> __int128_t</span><span style="color:white"> </span><span style="color:green">'__int128'</span><span style="color:white"> <br></span><span style="color:navy">|-</span><span style="color:lime">TypedefDecl</span><span style="color:olive"> 0x4b6b600</span><span style="color:white"> <</span><span style="color:olive"><invalid sloc></span><span style="color:white">> </span><span style="color:olive"><invalid sloc></span><span style="color:white"> implicit</span><span style="color:aqua"> __uint128_t</span><span style="color:white"> </span><span style="color:green">'unsigned __int128'</span><span style="color:white"> <br></span><span style="color:navy">|-</span><span style="color:lime">TypedefDecl</span><span style="color:olive"> 0x4b6b9c0</span><span style="color:white"> <</span><span style="color:olive"><invalid sloc></span><span style="color:white">> </span><span style="color:olive"><invalid sloc></span><span style="color:white"> implicit</span><span style="color:aqua"> __builtin_va_list</span><span style="color:white"> </span><span style="color:green">'__va_list_tag [1]'</span><span style="color:white"> <br></span><span style="color:navy">|-</span><span style="color:lime">CXXRecordDecl</span><span style="color:olive"> 0x4b6ba10</span><span style="color:white"> <</span><span style="color:olive">/tmp/cxxXX38p7:1:1</span><span style="color:white">, </span><span style="color:olive">line:3:1</span><span style="color:white">> </span><span style="color:olive">line:1:7</span><span style="color:white"> class</span><span style="color:aqua"> Foo</span><span style="color:white"> definition<br></span><span style="color:navy">| |-</span><span style="color:lime">CXXRecordDecl</span><span style="color:olive"> 0x4b6bb20</span><span style="color:white"> <</span><span style="color:olive">col:1</span><span style="color:white">, </span><span style="color:olive">col:7</span><span style="color:white">> </span><span style="color:olive">col:7</span><span style="color:white"> implicit class</span><span style="color:aqua"> Foo</span><span style="color:white"> <br></span><span style="color:navy">| `-</span><span style="color:lime">VarDecl</span><span style="color:olive"> 0x4b6bbc0</span><span style="color:white"> <</span><span style="color:olive">line:2:2</span><span style="color:white">, </span><span style="color:olive">col:13</span><span style="color:white">> </span><span style="color:olive">col:13</span><span style="color:aqua"> poop</span><span style="color:white"> </span><span style="color:green">'int'</span><span style="color:white"> static<br></span><span style="color:navy">`-</span><span style="color:lime">VarDecl</span><span style="color:olive"> 0x4b6bc50</span><span style="color:white"> parent 0x4b6ba10 prev 0x4b6bbc0 <</span><span style="color:olive">line:5:1</span><span style="color:white">, </span><span style="color:olive">col:17</span><span style="color:white">> </span><span style="color:olive">col:10</span><span style="color:aqua"> poop</span><span style="color:white"> </span><span style="color:green">'int'</span><span style="color:white"> cinit<br></span><span style="color:navy"> `-</span><span style="color:fuchsia">IntegerLiteral</span><span style="color:olive"> 0x4b6bd00</span><span style="color:white"> <</span><span style="color:olive">col:17</span><span style="color:white">> </span><span style="color:green">'int'</span><span style="color:aqua"> 3</span><span style="color:white"> </span></span></pre></div></div></div>