<div dir="ltr">Unfortunately, AST dumping and printing need a fair amount of work. We really just need someone to take this on as a project. I literally have a sticky note on my monitor which says "printing needs love", but its been there for some time.<div>
<br></div><div>I think the main thing is to move the printing logic which is in Driver/ASTConsumers.cpp and merge it with the StmtPrinting stuff. This way they can reuse the same pretty printing infrastructure. Once that work is done it will be much easier to just add things on a case by case basis.</div>
<div><br></div><div>For now, the unfortunate truth is that -ast-dump and -ast-print don't work very well, when something appears incorrect it is more often than not a problem in the printing rather than a problem in the AST representation.</div>
<div><br></div><div> - Daniel</div><div><br></div><div><div class="gmail_quote">On Fri, Oct 17, 2008 at 1:54 PM, Nick Galbreath <span dir="ltr"><<a href="mailto:nickg@modp.com">nickg@modp.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi there,<br>
I'm new to clang, so please bet gentle.<br>
<br>
On revision 57719, debug build<br>
<br>
I'm a bit confused on the -ast-dump/print output.  It seems to be not<br>
printing global declarations.  I don't know if this is a "feature" or<br>
"bug" or perhaps me not understanding what should be in the AST.   I<br>
read the bug reports but didn't see anything relevant.  Oddly<br>
emit-html correctly prints out everything.<br>
<br>
here's some examples:<br>
<br>
"""<br>
int i = 0;<br>
"""<br>
<br>
gets turned into<br>
<br>
"""<br>
$ clang -ast-print junk.c<br>
typedef char *__builtin_va_list;<br>
Read top-level variable decl: 'i'<br>
"""<br>
<br>
which smells wrong... locals seems to be ok<br>
<br>
But...<br>
<br>
"""<br>
void f() {<br>
  int i = 0;<br>
}<br>
"""<br>
<br>
becomes<br>
<br>
"""<br>
typedef char *__builtin_va_list;<br>
void f() {<br>
  int i = 0;<br>
}<br>
"""<br>
<br>
<br>
However, enums are also strange:<br>
<br>
Something like<br>
{{{<br>
int f(void) {<br>
  enum color { RED, GREEN, BLUE};<br>
  enum color x = RED;<br>
  switch (x) {<br>
  case RED: return 1;<br>
  case GREEN: return 2;<br>
  case BLUE: return 3;<br>
  }<br>
}<br>
"""<br>
<br>
gets turned into:<br>
<br>
"""<br>
typedef char *__builtin_va_list;<br>
<br>
int f() {<br>
  enum color;<br>
  enum color x = RED;<br>
  switch ((x)) {<br>
  case RED:<br>
    return 1;<br>
  case GREEN:<br>
    return 2;<br>
  case BLUE:<br>
    return 3;<br>
  }<br>
}<br>
<br>
which zapped away all the enum declarations.<br>
<br>
""""<br>
<br>
thoughts?<br>
<br>
--nickg<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div></div>