Hi,

Here is the updated patch which also generates the case statements for 
AttributeList::getKind, along with a fix to normalize the name of generated 
attribute enumerator.

Please review, thanks!

Michael

From: Michael Han
Sent: Tuesday, February 21, 2012 4:46 PM
To: [email protected]
Subject: [Patch][Review Request] Improve Clang attribute system

Hi,

I am starting working on a set of patches that aim at making the process of 
adding attribute extensions to Clang more automated, and less error prone. 
Currently, to add an attribute, besides modify the attribute TD file, one has 
to modify several entries in Sema, and such manual effort could be automated 
the same way attribute parsing is automated in parser via table gen. This will 
hopefully save a lot of boilerplate code, and make maintaining attributes 
easier.

So, my plan is to try to kill the attribute code in Sema that looks like could 
be generated in table gen. I remember someone mentioned that ultimately the 
AttributeList should be removed also but I felt it is too aggressive for me so 
I am going the incremental approach by starting refactoring existing attributes 
code in Sema into table gen, with the hope once it is done we don't need 
AttributeList anymore : )

Here is the first patch that generate the attribute kind enumeration list from 
Attr.td. I noticed that some attributes in Attr.td does not have an entry in 
Sema AttributeList, for example, here is the list

AlignMac68k
AsmLabel
Final
MBlazeInterruptHandler
MBlazeSaveVoliles
MSP430Interrupt
MaxFieldAlignment
Override

I added a bit field "SemaHandler" in Attr.td and this value is by default set 
to 1 since most of attributes described in Attr.td has entry in AttributeList. 
For the attributes in the above list, this field is set to 0 so there would not 
be entry generated for them in AttributeList (though.. it seems no harm to 
generate the entries for them..)

Also, some entries in AttributeList are not present in Attr.td, here is the list
_address_space
_base_check
_cf_returns_autoreleased
_ext_vector_type
_mode
_neon_polyvector_type
_neon_vector_type
_objc_gc
_objc_ownership
_opencl_image_access
_vector_size,

I simply hard code them in the enumeration list with the enumerators generated 
by table gen together. Also, since the enumerator names are generated 
automatically they may differ slightly in spelling comparing to some of hand 
coded enumerators, so I also updated several places to use new enumerator.

Please review and let me know if this is the right direction to go. Then, I 
will start moving more code into table gen, like the AttributeList::getKind, 
and refactor common semantic checking code like argument checking into table 
gen too. Thanks!

Cheers
Michael

Attachment: sema_attr.patch
Description: sema_attr.patch

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to