[cfe-commits] [PATCH] More Docs: Mastering the Clang AST

Richard Smith richard at metafoo.co.uk
Mon Jul 23 12:44:50 PDT 2012


On Mon, Jul 23, 2012 at 2:24 AM, Manuel Klimek <klimek at google.com> wrote:

> On Thu, Jul 19, 2012 at 10:46 PM, Richard Smith <richard at metafoo.co.uk>
> wrote:
> > On Thu, Jul 19, 2012 at 1:26 AM, Manuel Klimek <klimek at google.com>
> wrote:
> >>
> >> Any comments on the content of the doc, or do you guys think it's fine
> >> to go in? :)
> >
> >
> > 'targetted': the more common spelling is with only 2 't's.
>
> Done
>
> >
> >> $ clang -cc1 -ast-dump-xml test.cc
> >> ... cutting out internal declarations of clang ...
> >
> > I'd suggest also adding -undef to this command, to reduce the bulk of the
> > internal declarations. In an ideal world, that'd remove all of them, but
> we
> > still include __int64_t and friends in that mode :(
>
> Done
>
> >
> >> In general, -ast-dump-xml dumps declarations as XML and statements as
> >> S-expressions.
> >
> > This promises more than we deliver. ... "dumps declarations in an
> XML-style
> > format and statements in an S-expression-style format" is closer to the
> > truth :)
>
> Done
>
> >
> >>  declaration statement that delcares our result variable
> >
> > Typo: 'delcares'
>
> Done
>
> >
> >> Clang's AST nodes are modeled on a type hierarchy that does not have a
> >> common ancestor.
> >
> > s/type/class/, to avoid confusion with clang::Type.
>
> Done
>
> >
> >> Instead, there are multiple larger hierarchies for basic node types like
> >> Decl and Stmt.
> >
> > It might be useful to say that many of the important AST nodes derive
> from
> > Type, Decl, DeclContext or Stmt, with some classes deriving from both
> Decl
> > and DeclContext.
>
> Done
>
> >
> > I think the document could do with some discussion of the Type hierarchy,
> > QualType, canonical types and type sugar.
>
> Next iteration? :)
>

OK :)

> It is targeted at Developers

Lowercase 'd'.

> Clang's AST is different from ASTs of other languages in that it closely
resembles both the written C++ code and the C++ standard.

Perhaps this should say 'Clang's AST is different from ASTs produced by
some other compilers'? I can't imagine any other language would have a
compiler whose AST closely resembles C++ code and the C++ standard ;)

> Clang has a builtin AST-dump mode, which can be enabled with the flags
-ast-dump and -ast-dump-xml.

[...] has built-in AST-dump mode*s* ?

You should mention that a debug build is necessary for -ast-dump-xml to
produce output.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120723/17a91c37/attachment.html>


More information about the cfe-commits mailing list