[cfe-commits] [PATCH] FunctionTypeLoc local source range

Enea Zaffanella zaffanella at cs.unipr.it
Tue Sep 18 05:48:59 PDT 2012


Please find attached a patch for review.

The patch implements two changes in the TypeLoc area:

1) it enhances FunctionTypeLoc by adding locations for left and right 
parentheses; these are needed by client applications and, in C++, may 
differ from the local start/end source locations.

2) it fixes the computation of the local start/end source location of a 
FunctionProtoTypeLoc, taking into account the case of a trailing return 
type. For a function having a trailing return type, the local start 
location is set to the `auto' keyword and the local end location is set 
to the location of `->'.

Regarding 2, the following code can be used to show that the source 
location info currently computed by clang is suboptimal:

void foo() {
   _Generic(true, auto (*)()->int : 1, auto (*)()->int : 2);
}

(Side note: how can we turn this into a proper testcase? Are there 
expected-error variants checking for source location ranges?)

Enea.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: FunctionTypeLoc.patch
Type: text/x-diff
Size: 26877 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120918/aaa81e3a/attachment.patch>


More information about the cfe-commits mailing list