[cfe-dev] Decls and Attrs

Vassil Vassilev vasil.georgiev.vasilev at cern.ch
Thu Aug 15 02:00:45 PDT 2013


On 08/14/2013 03:24 PM, Aaron Ballman wrote:
> Ah, no, I misunderstood your question.  Sorry about that!
No problem.
>
> And no, there is no direct link from an attribute back to a decl.  For
> instance, the attribute could be attached to a type or a stmt, as well
> as a decl.
IIUC, the policy is clang should/will generate just one attribute of a 
kind and this attribute will be reused, even though now the 
implementation seems doing it otherwise:
grep -rni "new ([a-zA-Z].*) [a-zA-Z].*Attr(" clang/lib/ ...
> However, the Decl does not own its Attrs; the ASTContext does.  So you
> could modify the ASTContext to tell you which Decls an Attr is
> attached to if you only care about Decls.
How I can do that? The only way that comes to my mind is iterating over 
all decls and asking for their attr...
Vassil
>
> ~Aaron
>
> On Wed, Aug 14, 2013 at 9:04 AM, Vassil Vassilev
> <vasil.georgiev.vasilev at cern.ch> wrote:
>> Hi Aaron,
>>    Maybe I misundertand. My question is actually the inverse. Given that I
>> have an attribute can I find which decl it is attached to?
>> Vassil
>>
>> On 08/14/2013 03:00 PM, Aaron Ballman wrote:
>>> Yes, you can do it -- you can call Decl::addAttr to add the attributes
>>> to the declaration, and then use Decl::specific_attr_begin and
>>> Decl::specific_attr_end to iterate over the attributes of a specific
>>> kind on the declaration.
>>>
>>> Take a look at getVisibilityOf where it attempts to get the
>>> AvailabilityAttrs on a Decl if you'd like an example.
>>>
>>> ~Aaron
>>>
>>> On Wed, Aug 14, 2013 at 4:00 AM, Vassil Vassilev
>>> <vasil.georgiev.vasilev at cern.ch> wrote:
>>>> Hi!
>>>>     Maybe a silly question but can two Decls be annotated with the same
>>>> Attr
>>>> pointer in the AST? Said differently why there is no
>>>> clang::Attr::getDecl()
>>>>     Thanks!
>>>> Vassil
>>>> _______________________________________________
>>>> cfe-dev mailing list
>>>> cfe-dev at cs.uiuc.edu
>>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>




More information about the cfe-dev mailing list