[cfe-dev] automatically generated declarations in the AST

Douglas Gregor dgregor at apple.com
Thu Aug 19 10:13:24 PDT 2010


On Aug 19, 2010, at 3:33 AM, Jan Bierbaum wrote:

> Hi!
> 
> Is there any mechanism to identify automatically generated nodes inside
> the AST? I found CXXRecordDecl::hasDeclaredDefaultConstructor() etc. but
> there are also other auto generated nodes. I tried to use the source
> location but this is not consistent, e.g. the auto generated ctors do
> have a valid source location despite not having any source code.

Decl::isImplicit()

> Another issue are anonymous namespaces. After the first occurrence,
> Clang will insert an using directive. Fine. The problem is, that this
> directive does have a valid source location, but the namespace
> declarations don't. The beginning of their SourceRanges is invalid, the
> end is correct. Is this intended behavior? How can I get the correct
> start locations?


The using declaration is marked "implicit", so you can determine that we're in this case with Decl::isImplicit(). However, the broken SourceRange is a bug. Please file a bug at llvm.org/bugs or, better yet, provide a fix :)

	- Doug



More information about the cfe-dev mailing list