How to add a new keyword to clang, a keyword that will be considered as the main?

How to add a new keyword in clang? The new keyword must be a function specifier. Where does the declaration go?

Thanks.

+7
source share
1 answer

You should add it to include / clang / Basic / TokenKinds.def, and then add a new case to ParseDeclarationSpecifiers (...).

Probably a simpler option would be to define a new attribute and then use

#define your_new_qualifier __attribute__((your_new_attribute))

Otherwise, you will have to add this qualifier support to the AST, which may be error prone, while attributes automatically propagate to different declarations of the same function.

+7
source

All Articles