[cfe-dev] rewriting types of function declarations

Chris Lattner clattner at apple.com
Mon Jun 2 22:50:30 PDT 2008


On Jun 2, 2008, at 6:14 AM, Stephan Creutz wrote:
> is it possible to rewrite types in function declarations or better in
> named declarations? It seems there is no location information  
> available
> for types.

Hi Stephan,

You're right that types don't have location information.  Since they  
are unique'd, there is a many to one mapping between type instances  
and the underlying type.  It would be possible to capture this  
information, but would be extremely expensive.

For most uses, a fuzzy scanning technique can be used to find the  
locations you need in the original source.  Given a source location  
for the paramdecl, for example, you can get a "const char*" into the  
original source code and scan from there with strchr etc.  This is  
what the objc rewriter does in many cases.

-Chris



More information about the cfe-dev mailing list