[cfe-commits] r118238 - in /cfe/trunk: lib/CodeGen/CGRTTI.cpp lib/Sema/SemaOverload.cpp test/CodeGenCXX/nullptr.cpp test/CodeGenCXX/rtti-fundamental.cpp

Anders Carlsson andersca at mac.com
Wed Nov 3 22:28:09 PDT 2010


Author: andersca
Date: Thu Nov  4 00:28:09 2010
New Revision: 118238

URL: http://llvm.org/viewvc/llvm-project?rev=118238&view=rev
Log:
std::nullptr_t is a fundamental type for RTTI purposes.

Modified:
    cfe/trunk/lib/CodeGen/CGRTTI.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/CodeGenCXX/nullptr.cpp
    cfe/trunk/test/CodeGenCXX/rtti-fundamental.cpp

Modified: cfe/trunk/lib/CodeGen/CGRTTI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRTTI.cpp?rev=118238&r1=118237&r2=118238&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGRTTI.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGRTTI.cpp Thu Nov  4 00:28:09 2010
@@ -187,13 +187,14 @@
   //   Basic type information (e.g. for "int", "bool", etc.) will be kept in
   //   the run-time support library. Specifically, the run-time support
   //   library should contain type_info objects for the types X, X* and 
-  //   X const*, for every X in: void, bool, wchar_t, char, unsigned char, 
-  //   signed char, short, unsigned short, int, unsigned int, long, 
-  //   unsigned long, long long, unsigned long long, float, double, long double, 
-  //   char16_t, char32_t, and the IEEE 754r decimal and half-precision 
-  //   floating point types.
+  //   X const*, for every X in: void, std::nullptr_t, bool, wchar_t, char,
+  //   unsigned char, signed char, short, unsigned short, int, unsigned int,
+  //   long, unsigned long, long long, unsigned long long, float, double,
+  //   long double, char16_t, char32_t, and the IEEE 754r decimal and 
+  //   half-precision floating point types.
   switch (Ty->getKind()) {
     case BuiltinType::Void:
+    case BuiltinType::NullPtr:
     case BuiltinType::Bool:
     case BuiltinType::WChar:
     case BuiltinType::Char_U:
@@ -222,9 +223,6 @@
     case BuiltinType::UndeducedAuto:
       assert(false && "Should not see this type here!");
       
-    case BuiltinType::NullPtr:
-      assert(false && "FIXME: nullptr_t is not handled!");
-
     case BuiltinType::ObjCId:
     case BuiltinType::ObjCClass:
     case BuiltinType::ObjCSel:
@@ -934,16 +932,16 @@
 }
 
 void CodeGenModule::EmitFundamentalRTTIDescriptors() {
-  QualType FundamentalTypes[] = { Context.VoidTy, Context.Char32Ty,
-                                  Context.Char16Ty, Context.UnsignedLongLongTy,
-                                  Context.LongLongTy, Context.WCharTy,
-                                  Context.UnsignedShortTy, Context.ShortTy,
-                                  Context.UnsignedLongTy, Context.LongTy,
-                                  Context.UnsignedIntTy, Context.IntTy,
-                                  Context.UnsignedCharTy, Context.FloatTy,
-                                  Context.LongDoubleTy, Context.DoubleTy,
-                                  Context.CharTy, Context.BoolTy,
-                                  Context.SignedCharTy };
+  QualType FundamentalTypes[] = { Context.VoidTy, Context.NullPtrTy,
+                                  Context.BoolTy, Context.WCharTy,
+                                  Context.CharTy, Context.UnsignedCharTy,
+                                  Context.SignedCharTy, Context.ShortTy, 
+                                  Context.UnsignedShortTy, Context.IntTy,
+                                  Context.UnsignedIntTy, Context.LongTy, 
+                                  Context.UnsignedLongTy, Context.LongLongTy, 
+                                  Context.UnsignedLongLongTy, Context.FloatTy,
+                                  Context.DoubleTy, Context.LongDoubleTy,
+                                  Context.Char16Ty, Context.Char32Ty };
   for (unsigned i = 0; i < sizeof(FundamentalTypes)/sizeof(QualType); ++i)
     EmitFundamentalRTTIDescriptor(FundamentalTypes[i]);
 }

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=118238&r1=118237&r2=118238&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Nov  4 00:28:09 2010
@@ -986,7 +986,7 @@
     } else {
       return false;
     }
-  } 
+  }
   // Lvalue-to-rvalue conversion (C++ 4.1):
   //   An lvalue (3.10) of a non-function, non-array type T can be
   //   converted to an rvalue.

Modified: cfe/trunk/test/CodeGenCXX/nullptr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/nullptr.cpp?rev=118238&r1=118237&r2=118238&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/nullptr.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/nullptr.cpp Thu Nov  4 00:28:09 2010
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 -std=c++0x -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
 
+#include <typeinfo>
+
+// CHECK: @_ZTIDn = external constant i8*
 int* a = nullptr;
 
 void f() {
@@ -15,3 +18,7 @@
   // CHECK: call i8* @_Z11get_nullptrv()
   int (X::*pmf)(int) = get_nullptr();
 }
+
+const std::type_info& f2() {
+  return typeid(nullptr_t);
+}
\ No newline at end of file

Modified: cfe/trunk/test/CodeGenCXX/rtti-fundamental.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/rtti-fundamental.cpp?rev=118238&r1=118237&r2=118238&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/rtti-fundamental.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/rtti-fundamental.cpp Thu Nov  4 00:28:09 2010
@@ -14,60 +14,103 @@
   __fundamental_type_info::~__fundamental_type_info() { }
 }
 
+// void
 // CHECK: @_ZTIv = constant
 // CHECK: @_ZTIPv = constant
 // CHECK: @_ZTIPKv = constant
-// CHECK: @_ZTIDi = constant
-// CHECK: @_ZTIPDi = constant
-// CHECK: @_ZTIPKDi = constant
-// CHECK: @_ZTIDs = constant
-// CHECK: @_ZTIPDs = constant
-// CHECK: @_ZTIPKDs = constant
-// CHECK: @_ZTIy = constant
-// CHECK: @_ZTIPy = constant
-// CHECK: @_ZTIPKy = constant
-// CHECK: @_ZTIx = constant
-// CHECK: @_ZTIPx = constant
-// CHECK: @_ZTIPKx = constant
+
+// std::nullptr_t
+// CHECK: @_ZTIDn = constant
+// CHECK: @_ZTIPDn = constant
+// CHECK: @_ZTIPKDn = constant
+
+// bool
+// CHECK: @_ZTIb = constant
+// CHECK: @_ZTIPb = constant
+// CHECK: @_ZTIPKb = constant
+
+// wchar_t
 // CHECK: @_ZTIw = constant
 // CHECK: @_ZTIPw = constant
 // CHECK: @_ZTIPKw = constant
-// CHECK: @_ZTIt = constant
-// CHECK: @_ZTIPt = constant
-// CHECK: @_ZTIPKt = constant
+
+// char
+// CHECK: @_ZTIc = constant
+// CHECK: @_ZTIPc = constant
+// CHECK: @_ZTIPKc = constant
+
+// unsigned char
+// CHECK: @_ZTIh = constant
+// CHECK: @_ZTIPh = constant
+// CHECK: @_ZTIPKh = constant
+
+// signed char
+// CHECK: @_ZTIa = constant
+// CHECK: @_ZTIPa = constant
+// CHECK: @_ZTIPKa = constant
+
+// short
 // CHECK: @_ZTIs = constant
 // CHECK: @_ZTIPs = constant
 // CHECK: @_ZTIPKs = constant
-// CHECK: @_ZTIm = constant
-// CHECK: @_ZTIPm = constant
-// CHECK: @_ZTIPKm = constant
-// CHECK: @_ZTIl = constant
-// CHECK: @_ZTIPl = constant
-// CHECK: @_ZTIPKl = constant
-// CHECK: @_ZTIj = constant
-// CHECK: @_ZTIPj = constant
-// CHECK: @_ZTIPKj = constant
+
+// unsigned short
+// CHECK: @_ZTIt = constant
+// CHECK: @_ZTIPt = constant
+// CHECK: @_ZTIPKt = constant
+
+// int
 // CHECK: @_ZTIi = constant
 // CHECK: @_ZTIPi = constant
 // CHECK: @_ZTIPKi = constant
-// CHECK: @_ZTIh = constant
-// CHECK: @_ZTIPh = constant
-// CHECK: @_ZTIPKh = constant
+
+// unsigned int
+// CHECK: @_ZTIj = constant
+// CHECK: @_ZTIPj = constant
+// CHECK: @_ZTIPKj = constant
+
+// long
+// CHECK: @_ZTIl = constant
+// CHECK: @_ZTIPl = constant
+// CHECK: @_ZTIPKl = constant
+
+// unsigned long
+// CHECK: @_ZTIm = constant
+// CHECK: @_ZTIPm = constant
+// CHECK: @_ZTIPKm = constant
+
+// long long
+// CHECK: @_ZTIx = constant
+// CHECK: @_ZTIPx = constant
+// CHECK: @_ZTIPKx = constant
+
+// unsigned long long
+// CHECK: @_ZTIy = constant
+// CHECK: @_ZTIPy = constant
+// CHECK: @_ZTIPKy = constant
+
+// float
 // CHECK: @_ZTIf = constant
 // CHECK: @_ZTIPf = constant
 // CHECK: @_ZTIPKf = constant
-// CHECK: @_ZTIe = constant
-// CHECK: @_ZTIPe = constant
-// CHECK: @_ZTIPKe = constant
+
+// double
 // CHECK: @_ZTId = constant
 // CHECK: @_ZTIPd = constant
 // CHECK: @_ZTIPKd = constant
-// CHECK: @_ZTIc = constant
-// CHECK: @_ZTIPc = constant
-// CHECK: @_ZTIPKc = constant
-// CHECK: @_ZTIb = constant
-// CHECK: @_ZTIPb = constant
-// CHECK: @_ZTIPKb = constant
-// CHECK: @_ZTIa = constant
-// CHECK: @_ZTIPa = constant
-// CHECK: @_ZTIPKa = constant
+
+// long double
+// CHECK: @_ZTIe = constant
+// CHECK: @_ZTIPe = constant
+// CHECK: @_ZTIPKe = constant
+
+// char16_t
+// CHECK: @_ZTIDs = constant
+// CHECK: @_ZTIPDs = constant
+// CHECK: @_ZTIPKDs = constant
+
+// char32_t
+// CHECK: @_ZTIDi = constant
+// CHECK: @_ZTIPDi = constant
+// CHECK: @_ZTIPKDi = constant
+





More information about the cfe-commits mailing list