r274202 - [MS ABI] Pick an inheritance model if we resolve an overload set

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 29 20:02:03 PDT 2016


Author: majnemer
Date: Wed Jun 29 22:02:03 2016
New Revision: 274202

URL: http://llvm.org/viewvc/llvm-project?rev=274202&view=rev
Log:
[MS ABI] Pick an inheritance model if we resolve an overload set

We didn't assign an inheritance model for 'Foo' if the event an
exrepssion like '&Foo::Bar' occured if 'Bar' could resolve to multiple
functions.

Once the overload set is resolved to a particular member, we enforce a
specific inheritance model.

This fixes PR28360.

Added:
    cfe/trunk/test/CodeGenCXX/pr28360.cpp
Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=274202&r1=274201&r2=274202&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Jun 29 22:02:03 2016
@@ -13021,6 +13021,9 @@ Expr *Sema::FixOverloadedFunctionReferen
           = Context.getTypeDeclType(cast<RecordDecl>(Method->getDeclContext()));
         QualType MemPtrType
           = Context.getMemberPointerType(Fn->getType(), ClassType.getTypePtr());
+        // Under the MS ABI, lock down the inheritance model now.
+        if (Context.getTargetInfo().getCXXABI().isMicrosoft())
+          (void)isCompleteType(UnOp->getOperatorLoc(), MemPtrType);
 
         return new (Context) UnaryOperator(SubExpr, UO_AddrOf, MemPtrType,
                                            VK_RValue, OK_Ordinary,

Added: cfe/trunk/test/CodeGenCXX/pr28360.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pr28360.cpp?rev=274202&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/pr28360.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/pr28360.cpp Wed Jun 29 22:02:03 2016
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple i686-pc-win32 | FileCheck %s
+struct A {
+  void Foo();
+  void Foo(int);
+};
+
+using MpTy = void (A::*)();
+
+void Bar(const MpTy &);
+
+void Baz() { Bar(&A::Foo); }
+
+// CHECK-LABEL: define void @"\01?Baz@@YAXXZ"(
+// CHECK:  %[[ref_tmp:.*]] = alloca i8*, align 4
+// CHECK: store i8* bitcast (void (%struct.A*)* @"\01?Foo at A@@QAEXXZ" to i8*), i8** %[[ref_tmp]], align 4
+// CHECK: call void @"\01?Bar@@YAXABQ8A@@AEXXZ at Z"(i8** dereferenceable(4) %[[ref_tmp]])




More information about the cfe-commits mailing list