[cfe-dev] Add attributes to Types (as found in Decl)

Nuno Lopes nunoplopes at sapo.pt
Tue Apr 29 15:39:45 PDT 2008


> On Apr 25, 2008, at 12:04 PM, Nuno Lopes wrote:
>>> I was trying to implement the transparent_union type attribute, but I
>>> think
>>> we need some additional API to handle it. I think we should add the
>>> attribute API as found in Decl to Type (i.e. addAttr(),  getAttrs(), 
>>> ...).
>>> This could be used to implement this attribute and all the others  type
>>> attributes
>>> (http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Type-Attributes.html).
>>> Alternatively we could just add an ad-hoc field to the RecordType 
>>> struct
>>> to
>>> record if it's a transparent union or not, which also makes sense.
>>>
>>> Please give me some feedback.
>
> Hi Nuno,
>
> I think this is possible to do.  The 'problem' with this is that types 
> are uniqued, so we have to think carefully about how attributes mix  with 
> this.  I think the only sane solution is to have some canonical  ordering 
> of attribute lists and have the attribute list be part of the  type.
>
> What do you think?

Well I really didn't remember of that issue. We can have two identical 
types, but one is e.g. deprecated and the other isn't.. And 2 types may be 
identical but have different aligments, so my ASTContext proposal doesn't 
seem valid either.
So I think your solution may be the best one as far as I can tell. I'll try 
to cook up some patch somewhere before the end of July :) (yes, I'm 
overloaded with work..)

Thanks,
Nuno 




More information about the cfe-dev mailing list