[cfe-dev] AST Representation

Reid Kleckner via cfe-dev cfe-dev at lists.llvm.org
Wed Feb 1 11:32:17 PST 2017


Yes, the clang "abstract syntax tree" is often jokingly referred to as the
"concrete syntax graph". We try to provide a generally useful
representation, but being a fast production C++ compiler comes first.
Clang's AST is very concrete. You have to know a lot about it to navigate
it. There is no "Node" base class that you can use as a cursor to navigate
around Decls, Exprs, Types, and TemplateArguments. Template instantiation,
the closest thing I can think of to cloning, is done relatively manually
with TreeTransform.

I think it would be nice to revisit the design of clang's AST to simplify
it, normalize it, and abstract it, but it is not a task to be taken
lightly, and I don't expect it to happen in the near future.

On Wed, Feb 1, 2017 at 8:44 AM, Gaetano Checinski via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> As the AST is not really a Tree as it seems to have circular references,
> working with the AST is sometimes a bit messy (eg. cloning).
>
> A while ago Stroustroup pointed me to Gabriel Dos Reis' work on a
> different approach to represent C++-AST: https://github.com/
> GabrielDosReis/ipr
> <https://mailtrack.io/trace/link/a5c184fad2cf94fbf0449fa233263072ebc34ea8?url=https%3A%2F%2Fgithub.com%2FGabrielDosReis%2Fipr&signature=9a19f2a0a41d5ceb>
>
> Did anyone try to integrate his work into clang or has an opinion to share
> ?
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170201/048f2b76/attachment.html>


More information about the cfe-dev mailing list