[cfe-dev] Return type of statement

Chris Lattner clattner at apple.com
Mon Jan 5 20:21:47 PST 2009


On Jan 5, 2009, at 6:31 PM, Alexei Svitkine wrote:

> Thanks for the pointers.
>
> What's the best way to map from a location in the source to the
> corresponding Stmt (and hence Expr if it is exists)?

There isn't an efficient way to do it.  You'd have to walk the whole  
function body and look at the source ranges that each stmt covers,  
stopping at the smallest one that covers the point of interest.  You  
could do this once and build a location -> stmt mapping of course.   
This would be useful if you do repeated queries (such as having a  
mouse float over code etc).

-Chris



More information about the cfe-dev mailing list