[cfe-dev] Adding to AST

Douglas Gregor dgregor at apple.com
Mon Sep 27 13:02:17 PDT 2010


On Sep 27, 2010, at 11:03 AM, Nadeem Ahmad wrote:

> Dear all:
> 
> I am new to the clang. I am trying to parse the following expression:
> 
> int foo() unsw { }
> 
> I am able to catch the variable "unsw" in the parse::ParseDeclGroup(). After consuming the token "unsw" using ConsumeToken(), I need to add it in the AST. My understanding is that I have to add some action in the Sema, most probably in the SemaDecl.cpp. Am I in the right direction? Any hint for me to put me in the right direction.


Yes, you're going in the right direction. You'll probably want to add a flag into the DeclSpec chunk for functions, to indicate that you parsed "unsw" (and perhaps it's source location). Then, when Sema analyzes the DeclSpec (for example, in Sema::ActOnFunctionDeclarator), it can act on the presence of "unsw". 

	- Doug



More information about the cfe-dev mailing list