That was my first thought but when I did if(dyn_cast< NamespaceDecl >(pDecl)) { ...code... }, I found that I wasn't hitting my breakpoint inside the if-block. Also pDecl->getDeclKindName() returns "Var" for all instances of Stuff (I would have expected 1 for the declaration of gThing but not the namespace too).<br>
<br>I also tried iterating through all of the items in the DeclGroupRef in HandleTopLevelDecl(...) and trying to recurse down through all Decls that successfully dyn_cast< DeclContext >.<br><br>(And the __builtin_va_list disappears when I copied used the SourceLocation::isInvalid() check from RewriteObjC::HandleTopLevelSingleDec(...) suggested as an example previously.)<br>
<br>Pascal<br><br><div class="gmail_quote">On 22 February 2010 23:19, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
On Feb 22, 2010, at 2:41 PM, Pascal Dennerly wrote:<br>
<br>
> ==Stuff.h==<br>
> namespace Stuff<br>
> {<br>
> template< typename A, int B ><br>
> class Thingy<br>
> {<br>
> public:<br>
> Thingy() {}<br>
><br>
> private:<br>
> int data;<br>
> };<br>
> }<br>
><br>
> ==Stuff.cpp==<br>
> #include "Stuff.h"<br>
> Stuff::Thingy< double, 2 > gThing;<br>
> void funcy()<br>
> {<br>
> int i;<br>
> i++;<br>
> }<br>
><br>
> I tried to write an AST consumer that would iterate over the Decls in the HandleTranslationUnit method but when I ran it over the above code only got __builtin_va_list (as a TypedefDecl) and 2 VarDecls as for "Stuff". I was expecting a RecordDecl for the Thingy class and decl for the class.<br>
><br>
> I don't suppose someone would be able to tell me why I'm so far off base?<br>
<br>
</div>The top-level declarations are __builtin_va_list (injected by the compiler), Stuff, gThing, and funcy.<br>
<br>
Thingy is not a top-level declaration; it's stored within the namespace 'Stuff'. You can iterate through the declarations within a namespace with decls_begin/decls_end; check out the DeclContext class for more information.<br>
<br>
- Doug</blockquote></div><br>