[cfe-commits] r89155 - in /cfe/trunk: lib/CodeGen/CGCXXExpr.cpp lib/CodeGen/CGRtti.cpp test/CodeGenCXX/rtti.cpp

Mike Stump mrs at apple.com
Tue Nov 17 14:33:01 PST 2009


Author: mrs
Date: Tue Nov 17 16:33:00 2009
New Revision: 89155

URL: http://llvm.org/viewvc/llvm-project?rev=89155&view=rev
Log:
Add rtti support for pointer to data members.

Modified:
    cfe/trunk/lib/CodeGen/CGCXXExpr.cpp
    cfe/trunk/lib/CodeGen/CGRtti.cpp
    cfe/trunk/test/CodeGenCXX/rtti.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXXExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXXExpr.cpp?rev=89155&r1=89154&r2=89155&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXXExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXXExpr.cpp Tue Nov 17 16:33:00 2009
@@ -359,6 +359,9 @@
     return Builder.CreateBitCast(CGM.GenerateRttiNonClass(Ty), LTy);
   }
   Expr *subE = E->getExprOperand();
+  Ty = subE->getType();
+  CanQualType CanTy = CGM.getContext().getCanonicalType(Ty);
+  Ty = CanTy.getUnqualifiedType().getNonReferenceType();
   if (const RecordType *RT = Ty->getAs<RecordType>()) {
     const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
     if (RD->isPolymorphic()) {
@@ -397,9 +400,6 @@
     }      
     return Builder.CreateBitCast(CGM.GenerateRtti(RD), LTy);
   }
-  Ty = subE->getType();
-  CanQualType CanTy = CGM.getContext().getCanonicalType(Ty);
-  Ty = CanTy.getUnqualifiedType().getNonReferenceType();
   return Builder.CreateBitCast(CGM.GenerateRttiNonClass(Ty), LTy);
 }
 

Modified: cfe/trunk/lib/CodeGen/CGRtti.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRtti.cpp?rev=89155&r1=89154&r2=89155&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGRtti.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRtti.cpp Tue Nov 17 16:33:00 2009
@@ -263,10 +263,13 @@
     std::vector<llvm::Constant *> info;
 
     QualType PTy = Ty->getPointeeType();
-    // FIXME: ptr-mem data
     QualType BTy;
-    // FIXME: ptr-mem data
     bool PtrMem = false;
+    if (const MemberPointerType *MPT = dyn_cast<MemberPointerType>(Ty)) {
+      PtrMem = true;
+      BTy = QualType(MPT->getClass(), 0);
+      PTy = MPT->getPointeeType();
+    }
 
     if (PtrMem)
       C = BuildVtableRef("_ZTVN10__cxxabiv129__pointer_to_member_type_infoE");
@@ -335,6 +338,8 @@
 
       return BuildPointerType(Ty);
     }
+    case Type::MemberPointer:
+      return BuildPointerType(Ty);
     }
   }
 };

Modified: cfe/trunk/test/CodeGenCXX/rtti.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/rtti.cpp?rev=89155&r1=89154&r2=89155&view=diff

==============================================================================
--- cfe/trunk/test/CodeGenCXX/rtti.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/rtti.cpp Tue Nov 17 16:33:00 2009
@@ -41,6 +41,23 @@
 // CHECK-NEXT: .space 4
 // CHECK-NEXT: .quad  __ZTIi
 
+// CHECK:    __ZTIM7test3_Ai:
+// CHECK-NEXT: .quad  (__ZTVN10__cxxabiv129__pointer_to_member_type_infoE) + 16
+// CHECK-NEXT: .quad  __ZTSM7test3_Ai
+// CHECK-NEXT: .space 4
+// CHECK-NEXT: .space 4
+// CHECK-NEXT: .quad  __ZTIi
+// CHECK-NEXT: .quad  __ZTI7test3_A
+
+// CHECK:__ZTIM7test3_Ii:
+// CHECK-NEXT: .quad  (__ZTVN10__cxxabiv129__pointer_to_member_type_infoE) + 16
+// CHECK-NEXT: .quad  __ZTSM7test3_Ii
+// CHECK-NEXT: .long  16
+// CHECK-NEXT: .space 4
+// CHECK-NEXT: .quad  __ZTIi
+// CHECK-NEXT: .quad  __ZTI7test3_I
+
+
 // CHECK:__ZTI7test1_D:
 // CHECK-NEXT: .quad (__ZTVN10__cxxabiv120__si_class_type_infoE) + 16
 // CHECK-NEXT: .quad __ZTS7test1_D
@@ -126,9 +143,9 @@
 // CHECK-LL-NEXT:  %vtable = load %"class.std::type_info"*** %0
 // CHECK-LL-NEXT:  %1 = getelementptr inbounds %"class.std::type_info"** %vtable, i64 -1
 // CHECK-LL-NEXT:  %2 = load %"class.std::type_info"** %1
-// CHECK-LL-NEXT:  %call = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* %2, %"class.std::type_info"* bitcast (%2* @_ZTI7test1_D to %"class.std::type_info"*))
+// CHECK-LL-NEXT:  %call = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* %2, %"class.std::type_info"* bitcast (%{{[0-9]*}}* @_ZTI7test1_D to %"class.std::type_info"*))
 
-// CHECK-LL:       %call2 = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* bitcast (%0* @_ZTI2NP to %"class.std::type_info"*), %"class.std::type_info"* bitcast (%2* @_ZTI7test1_D to %"class.std::type_info"*))
+// CHECK-LL:       %call2 = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* bitcast (%0* @_ZTI2NP to %"class.std::type_info"*), %"class.std::type_info"* bitcast (%{{[0-9]*}}* @_ZTI7test1_D to %"class.std::type_info"*))
 
 // CHECK-LL:       %3 = bitcast %class.test1_B7* %tmp5 to %"class.std::type_info"***
 // CHECK-LL-NEXT:  %4 = icmp ne %"class.std::type_info"*** %3, null
@@ -140,14 +157,20 @@
 // CHECK-LL-NEXT:  %vtable6 = load %"class.std::type_info"*** %3
 // CHECK-LL-NEXT:  %7 = getelementptr inbounds %"class.std::type_info"** %vtable6, i64 -1
 // CHECK-LL-NEXT:  %8 = load %"class.std::type_info"** %7
-// CHECK-LL-NEXT:  %call7 = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* %8, %"class.std::type_info"* bitcast (%2* @_ZTI7test1_D to %"class.std::type_info"*))
+// CHECK-LL-NEXT:  %call7 = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* %8, %"class.std::type_info"* bitcast (%{{[0-9]*}}* @_ZTI7test1_D to %"class.std::type_info"*))
 
 // CHECK-LL:       %call10 = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* bitcast (i8** @_ZTIi to %"class.std::type_info"*), %"class.std::type_info"* bitcast (i8** @_ZTIf to %"class.std::type_info"*))
 
 // CHECK-LL:       %call13 = call zeroext i1 @_ZNKSt9type_infoeqERKS_(%"class.std::type_info"* bitcast (i8** @_ZTIPi to %"class.std::type_info"*), %"class.std::type_info"* bitcast (i8** @_ZTIPKi to %"class.std::type_info"*))
 
+class test3_A { };
+class test3_I;
+int (test3_A::*pmd);
+int (test3_I::*i_pmd);
 int test3() {
   if (typeid(volatile int *) == typeid(int *))
     return 1;
+  if (typeid(pmd) == typeid(i_pmd))
+    return 1;
   return 0;
 }





More information about the cfe-commits mailing list