[cfe-dev] Return type of statement

Ted Kremenek kremenek at apple.com
Mon Jan 5 18:10:52 PST 2009


Alexei,

Statements that evalute to a value are known as expressions.   
Expressions are represented by the Expr class (which subclasses  
Stmt).  The method Expr::getType() will return the information you  
want.  I recommend looking at the Clang sources for example uses of  
this method.

On Jan 5, 2009, at 5:43 PM, Alexei Svitkine  
<alexei.svitkine at gmail.com> wrote:

> I am starting a project that will use clang. I'm asking to be pointed
> in the right direction with a question I have. Here goes.
>
> Given a context (ie a source file) and a statement somewhere in that
> file, what's the easiest way to find the return type of that statement
> with clang?
>
> For example, for an assignment, it's the type of the variable, for a
> function call, it's the return type, but obviously there are more
> complicated examples in C semantics.
>
> Surely, clang must be aware of this information, so what's the easiest
> way to get at it (using code)?
>
> -Alexei Svitkine
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list