[cfe-dev] Query "next" decl in a DeclGroup?

Eli Bendersky eliben at google.com
Thu Jun 12 15:48:15 PDT 2014


On Thu, Jun 12, 2014 at 3:39 PM, Richard Smith <richard at metafoo.co.uk>
wrote:

> On Thu, Jun 12, 2014 at 2:41 PM, Eli Bendersky <eliben at google.com> wrote:
>
>> Hi All,
>>
>> Given a Decl*, I want to find who are the other decls in its DeclGroup.
>> So for:
>>
>>   int foo, bar;
>>
>> Given a Decl* for 'foo', I want to find 'bar'.
>>
>> ASTConsumer.h (http://clang.llvm.org/doxygen/ASTConsumer_8h_source.html)
>> mentions a getNextDeclarator method, which seems to have been removed in
>> r68002 (so the comment is stale now).
>>
>> Any way to do this?
>>
>> One way I see is when the consumer defines HandleTopLevelDecl it gets the
>> whole group and can go over it. But what about somewhere deep in the
>> traversal, if all I have is a Decl*?
>>
>> There's getNextDeclInContext, but that goes beyond the group too.
>>
>
> I don't believe we have any explicit representation of top-level
> DeclGroups once we finish parsing. You may be able to reconstruct this
> information by looking at the source locations of declarations (if the
> source range of the next declaration in the lexical context overlaps the
> current declaration's range, then they're in the same group).
>

I was fearing you will say that :-) Thanks for the reply - I'll find a way
around it.

Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140612/152b9d76/attachment.html>


More information about the cfe-dev mailing list