[PATCH] [Sema] Make FunctionType's TSI use unadjusted argument types

Eli Friedman eli.friedman at gmail.com
Sat Jun 8 21:35:08 PDT 2013


On Sat, Jun 8, 2013 at 2:05 PM, Reid Kleckner <rnk at google.com> wrote:

> I don't think this approach is working very well.
>
> The problem is that I'm trying to keep the un-decayed array types in TSI,
> and these get propagated into many places they shouldn't.  My patch breaks
> tests like:
>
> void t22(void (*take_array(int array[1]))) {
>   int arr[1];
>   take_array(arr); // error: array initializer must be an initializer list
> }
>
> The problem is that GetFullTypeForDeclarator() returns a TypeSourceInfo,
> so all I have to do is nest the un-decayed type deep inside that TSI.  Then
> it becomes hard to find and adjust parameter types without doing a full
> traversal.
>
> The full traversal seems silly.  Maybe I should be changing the consumers
> of the function types to handle array types instead?
>
>
I think it makes sense for non-canonical FunctionTypes to keep around
undecayed array types as parameters.  Anything that queries a
FunctionTypeLoc for a should be prepared to run into undecayed array types
in parameters.  (It doesn't make sense to build a TypeSourceInfo for a
pointer which was never actually written in the code.)  It might make sense
for the default iterators/accessors for FunctionTypes to automatically
decay the parameter types, with an alternate version for anything that
really wants the undecayed type (e.g. the TypeLoc code).

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130608/e6731134/attachment.html>


More information about the cfe-commits mailing list