[PATCH] PR15291: noreturn adjustment in overload resolution for function templates

Douglas Gregor dgregor at apple.com
Tue Apr 16 09:41:12 PDT 2013


On Mar 7, 2013, at 8:39 PM, Alexander Zinenko <ftynse at gmail.com> wrote:

> Ping?

+bool Sema::SameTypesOrCompatibleFunctions(QualType Param,
+                                          QualType Arg) {

We're starting function names with a lowercase letter now. How about calling this isSameOrCompatibleFunctionType?

+  if (!ParamFunction || !ArgFunction)
+    return Param == Arg;

Please change the parameters to CanQualTypes, because these == operations only work because we know we're getting canonical types, and that's not clear from the interface.

+  if (IsNoReturnConversion(Param, Arg, AdjustedParam))
+    return Arg == AdjustedParam;

You'll probably need to recanonicalize AdjustedParam here.

+  // TODO(ftynse): Compatible calling conventions.
+  
Usually we just write "FIXME: what we need to fix"

Otherwise, this patch looks great!

	- Doug


> 
> On 26 February 2013 23:26, Alexander Zinenko <ftynse at gmail.com> wrote:
> Hello, John!
> 
> Thanks for your comments!
> I introduced a flag that allows noreturn mismatches only if template deduction is called during overload resolution.  It allowed also to use function calls only in these cases while just comparing pointers in all the other cases.
> 
> Just comparing types will not work unless noreturn and non-noreturn functions have the same type, but this is not the thing we want according to the recent discussion on PR15105.  While it is possible to build a similar function type without noreturn and compare against it, this would not work for implicit default calling conventions that require the same logic in overload as noreturn functions.
> 
> Is this patch better?
> 
> --
> Alex
> 
> 
> On 26 February 2013 02:48, John McCall <rjmccall at apple.com> wrote:
> On Feb 25, 2013, at 8:34 AM, Alexander Zinenko <ftynse at gmail.com> wrote:
> > This patch allows function templates with GNU noreturn attribute to participate in overload resolution as non-noreturn ones.  Same behavior is allowed for functions now.
> > The patch only allows deducing such types since the necessary adjustments are already performed in corresponding functions (like in IsStandardConversion).
> 
> This function does a lot of work to make sure that the final equality comparison is a (fast) pointer equality test, and you're replacing it with a (slow) function call.
> 
> Also, we definitely don't want to allow noreturn mismatches in every context.
> 
> John.
> 
> 
> 
> <PR15291.patch>_______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130416/14799c69/attachment.html>


More information about the cfe-commits mailing list