[cfe-dev] Type source info for function template instances.

Enea Zaffanella zaffanella at cs.unipr.it
Thu Mar 4 05:49:06 PST 2010


John McCall wrote:
> On Feb 18, 2010, at 3:17 PM, Enea Zaffanella wrote:
>> In our client application, we need to visit all instantiations of
 >> template declarations. While at it, we were surprised to notice that
 >> the instantiations of function template declarations are provided with
 >> a TypeSourceInfo object that seems to be an exact copy of the one found
 >> in the corresponding templated decl.

[...]

> This is definitely just an oversight; the fix required is
> more-or-less  what you've proposed, except ideally we would only
 > transform the type once. If you'd like to look into the bugs
 > this exposes, that would be great; otherwise, please file a bug on this.
> 
> John.
> 

Hello John.

One of the two errors was just due to the duplication of the expected 
diagnostics (since we were transforming twice the function parameters).

We haven't found a simple way to avoid this double transformation:
we can not just transform the parameters found in the function TSI 
(TypeSourceInfo), since this would disregard, e.g., default argument 
expressions. On the other hand, we found no (simple) way to separately 
transform the function declaration parameters and the function TSI 
components and then rebuild the full function TSI from those.

So we adopted the following approach: we keep transforming the function 
type and parameters as was done before, then we also transform the 
function TSI but, when doing this, we temporarily suppress all 
diagnostics, so that no repeated diagnostic is generated.
This implies a minor change in Diagnostic.h, where a Boolean flag 
becomes an unsigned char counter to be used by a RAII object.

The patch is attached (based on r97215, it passes all tests).

Cheers,
Enea Zaffanella.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Subst-Function-TInfo.patch
Type: text/x-patch
Size: 8064 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100304/f7a03a96/attachment.bin>


More information about the cfe-dev mailing list