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

Mike Stump mrs at apple.com
Mon Nov 16 18:57:13 PST 2009


Author: mrs
Date: Mon Nov 16 20:57:13 2009
New Revision: 89030

URL: http://llvm.org/viewvc/llvm-project?rev=89030&view=rev
Log:
Add typeinfo support for T* and const T* for all builtin types T.

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

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGRtti.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRtti.cpp Mon Nov 16 20:57:13 2009
@@ -253,6 +253,19 @@
       // We expect all type_info objects for builtin types to be in the library.
       return BuildTypeRef(Ty);
     }
+
+    case Type::Pointer: {
+      QualType PTy = Ty->getPointeeType();
+      Qualifiers Q = PTy.getQualifiers();
+      Q.removeConst();
+      // T* and const T* for all builtin types T are expected in the library.
+      if (isa<BuiltinType>(PTy) && Q.empty())
+        return BuildTypeRef(Ty);
+
+      assert(0 && "typeid expression");
+      const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
+      return llvm::Constant::getNullValue(Int8PtrTy);
+    }
     }
   }
 };

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

==============================================================================
--- cfe/trunk/test/CodeGenCXX/rtti.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/rtti.cpp Mon Nov 16 20:57:13 2009
@@ -106,6 +106,8 @@
     test2_1();
   if (typeid(int) == typeid(float))
     test2_1();
+  if (typeid(int*) == typeid(const int *))
+    test2_1();
 }
 
 // CHECK-LL:define void @_Z7test2_2P7test1_D(%class.test1_B7* %dp) nounwind {
@@ -130,4 +132,6 @@
 // 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 (%1* @_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"*)) ; <i1> [#uses=1]
+// 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"*))





More information about the cfe-commits mailing list