[cfe-dev] parsing a function in the Clang

Douglas Gregor dgregor at apple.com
Wed Sep 22 08:56:47 PDT 2010


On Sep 22, 2010, at 7:59 AM, Wei Li wrote:

> Dear all:
> 
> I am extending Clang for my work. One thing  I am extending is
> function body. I am inserting some key words between function name and
> the body of the function as following:
> 
> 
> int function(int x, int y) zone1 A[*][*], zone2 B[*][*] {
> 
> // zone1 and zone2 are my personal key words
> // A and B are 2D arrays
> 
>      int z;
>      z = x + y;
> 
> return z;
> }
> 
> Which files or methods should be modified for this in the Parser?


Don't try to add these keywords directly, because it will create a ton of extra work. Use attributes, and follow the many other function attributes in Clang through parsing/semantic analysis/AST/etc. to figure out what to modify.

	- Doug



More information about the cfe-dev mailing list