improve attributes handling in clang

Hi Doug,

I have a question on the plan of improving attribute handling in clang. I am aware that the attribute handling has been improved a lot with Sean’s work by using tblgen to generate boilerplate code such that getting attributes from source to AST is almost fully automated.

My question is, is there any plan and / or work to finish, in order to further improve the attribute handling in clang? For example, I noticed getting attributes from source to Sema still requires manually modifying the AttributeList in Sema (although the modification is quite trivial), which might be another place that can be automated using tblgen.

The motivation is we at Autodesk are developing a static code analyzer that checks function call graph through annotated GNU-style attributes acting as metadata associated with the function types and we are interested in improving attributes handling in clang to make it even more easier for user to add implementation defined attributes. Any suggestions and guidance on potential improvements are appreciated.

Cheers

Michael

Hi Doug,

I have a question on the plan of improving attribute handling in clang. I am aware that the attribute handling has been improved a lot with Sean’s work by using tblgen to generate boilerplate code such that getting attributes from source to AST is almost fully automated.

My question is, is there any plan and / or work to finish, in order to further improve the attribute handling in clang? For example, I noticed getting attributes from source to Sema still requires manually modifying the AttributeList in Sema (although the modification is quite trivial), which might be another place that can be automated using tblgen.

I'd love to see further improvements to attribute handling along the lines of what was in Sean's GSoC proposal, but I personally don't plan to work on this. Sean, are you planning to continue working on attributes?

The motivation is we at Autodesk are developing a static code analyzer that checks function call graph through annotated GNU-style attributes acting as metadata associated with the function types and we are interested in improving attributes handling in clang to make it even more easier for user to add implementation defined attributes. Any suggestions and guidance on potential improvements are appreciated.

The major improvements I'd still like to see are to automatically generate the parser for attributes (based on the .td file) and to do basic semantic checking + adding attributes to AST nodes (also based on the .td file).

  - Doug

Yes, I am absolutely intending to finish what was done. Classes end next week, and then I should have much more free time to rewrite the work I'd done to be compatible with the new Sema/Parser divide.

Sean

I think one improvement would be to move the AttributeList::Kind in Sema into td file so codes like AttributeList::getKind can be generated through tblgen. If this is done then adding an implementation defined (gnu style) attribute would only require user modify the attribute table definition file (with user's code to handle attributes in Sema but that's not part of infrastructure anyway). Currently when we add our attributes we need to visit several places in Sema to fix the boilerplate code.

Cheers
~Michael

My intent is to remove AttributeList entirely. Especially now that we have removed the Parser/Sema barrier, it makes no sense to have two separate data structures for the same thing.

Sean

That'll be even better! Thanks Sean and we are already benefit from your work on attributes :slight_smile:

Cheers
~Michael

Yes please :slight_smile:

That felt odd yesterday. I’d thrown it on my todo list not knowing if you were coming back. Now that you are, thanks!

-eric