r247248 - [MS ABI] Select a pointer to member representation more often

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 10 00:20:06 PDT 2015


Author: majnemer
Date: Thu Sep 10 02:20:05 2015
New Revision: 247248

URL: http://llvm.org/viewvc/llvm-project?rev=247248&view=rev
Log:
[MS ABI] Select a pointer to member representation more often

Given a reference to a pointer to member whose class's inheritance model
is unspecified, make sure we come up with an inheritance model in
plausible places.  One place we were missing involved LValue to RValue
conversion, another involved unary type traits.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprCXX.cpp
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=247248&r1=247247&r2=247248&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Sep 10 02:20:05 2015
@@ -677,6 +677,10 @@ ExprResult Sema::DefaultLvalueConversion
   if (T.hasQualifiers())
     T = T.getUnqualifiedType();
 
+  if (T->isMemberPointerType() &&
+      Context.getTargetInfo().getCXXABI().isMicrosoft())
+    RequireCompleteType(E->getExprLoc(), T, 0);
+
   UpdateMarkingForLValueToRValue(E);
   
   // Loading a __weak object implicitly retains the value, so we need a cleanup to 

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=247248&r1=247247&r2=247248&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Sep 10 02:20:05 2015
@@ -4507,6 +4507,8 @@ QualType Sema::CheckPointerToMemberOpera
       << OpSpelling << RHSType << RHS.get()->getSourceRange();
     return QualType();
   }
+  //if (Context.getTargetInfo().getCXXABI().isMicrosoft())
+  //  RequireCompleteType(Loc, QualType(MemPtr, 0), 0);
 
   QualType Class(MemPtr->getClass(), 0);
 

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=247248&r1=247247&r2=247248&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Sep 10 02:20:05 2015
@@ -6253,9 +6253,13 @@ bool Sema::RequireCompleteExprType(Expr
   QualType T = E->getType();
 
   // Fast path the case where the type is already complete.
-  if (!T->isIncompleteType())
+  if (!T->isIncompleteType()) {
+    if (T->isMemberPointerType() &&
+        Context.getTargetInfo().getCXXABI().isMicrosoft())
+      RequireCompleteType(E->getExprLoc(), T, 0);
     // FIXME: The definition might not be visible.
     return false;
+  }
 
   // Incomplete array types may be completed by the initializer attached to
   // their definitions. For static data members of class templates and for

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp?rev=247248&r1=247247&r2=247248&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-member-pointers.cpp Thu Sep 10 02:20:05 2015
@@ -752,3 +752,19 @@ void f(int S::*&p) {}
 // CHECK-LABEL: define void @"\01?f at PR24703@@YAXAAPQS at 1@H at Z"(
 }
 
+namespace ReferenceToMPTWithIncompleteClass {
+struct S;
+struct J;
+struct K;
+extern K *k;
+
+// CHECK-LABEL: @"\01?f at ReferenceToMPTWithIncompleteClass@@YAIAAPQS at 1@H at Z"(
+// CHECK: ret i32 12
+unsigned f(int S::*&p) { return sizeof p; }
+
+// CHECK-LABEL: @"\01?g at ReferenceToMPTWithIncompleteClass@@YA_NAAPQJ at 1@H0 at Z"(
+bool g(int J::*&p, int J::*&q) { return p == q; }
+
+// CHECK-LABEL: @"\01?h at ReferenceToMPTWithIncompleteClass@@YAHAAPQK at 1@H at Z"(
+int h(int K::*&p) { return k->*p; }
+}




More information about the cfe-commits mailing list