parsing a function in the Clang

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

parsing a function in the Clang

Wei Li
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?

Thanks,
--
Regards,

Wei Li
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: parsing a function in the Clang

Douglas Gregor

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
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev