Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you add a new keyword to clang, a keyword that would be treated as main?

Tags:

c++

c

clang

How can a new keyword be added to clang? The new keyword should be a function qualifier. Where would the declaration part go?

Thanks.

like image 245
marius c Avatar asked Jan 19 '11 14:01

marius c


1 Answers

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

Probably an easier option would be to define a new attribute, and then use

#define your_new_qualifier __attribute__((your_new_attribute))

Otherwise you'd have to add this qualifier support to the AST, which could be error-prone, whereas attributes are propagated automatically across various declarations of the same function.

like image 114
SK-logic Avatar answered Oct 06 '22 15:10

SK-logic