Merge pull request #1813 from rainers/cv11

DI: display typeof(null) as void*
This commit is contained in:
David Nadlinger 2016-10-08 11:37:10 +01:00 committed by GitHub
commit ba180bbde2
2 changed files with 31 additions and 29 deletions

View file

@ -658,15 +658,15 @@ ldc::DIType ldc::DIBuilder::CreateTypeDescription(Type *type, bool derefclass) {
t = type->toBasetype(); t = type->toBasetype();
} }
#if LDC_LLVM_VER >= 309
if (t->ty == Tnull)
return DBuilder.createNullPtrType();
if (t->ty == Tvoid) if (t->ty == Tvoid)
return nullptr; #if LDC_LLVM_VER >= 309
return nullptr;
#else #else
if (t->ty == Tvoid || t->ty == Tnull)
return DBuilder.createUnspecifiedType(t->toChars()); return DBuilder.createUnspecifiedType(t->toChars());
#endif #endif
if (t->ty == Tnull) // display null as void*
return DBuilder.createPointerType(CreateTypeDescription(Type::tvoid, false),
8, 8, "typeof(null)");
if (t->ty == Tvector) if (t->ty == Tvector)
return CreateVectorType(type); return CreateVectorType(type);
if (t->isintegral() || t->isfloating()) { if (t->isintegral() || t->isfloating()) {

View file

@ -9,37 +9,38 @@
// modulename explicitly unspecified to check implicit function name when breaking // modulename explicitly unspecified to check implicit function name when breaking
void main() void main()
{ {
basic_types(); basic_types();
} }
int basic_types() int basic_types()
{ {
char c = 'a'; char c = 'a';
wchar wc = 'b'; wchar wc = 'b';
dchar dc = 'c'; dchar dc = 'c';
byte b = 1; byte b = 1;
ubyte ub = 2; ubyte ub = 2;
short s = 3; short s = 3;
ushort us = 4; ushort us = 4;
int i = 5; int i = 5;
uint ui = 6; uint ui = 6;
long l = 7; long l = 7;
ulong ul = 8; ulong ul = 8;
float f = 9; float f = 9;
double d = 10; double d = 10;
real r = 11; real r = 11;
ifloat iflt = 12i;
idouble id = 13i;
ireal ir = 14i;
cfloat cf = 15 + 16i;
cdouble cd = 17 + 18i;
creal cr = 19 + 20i;
ifloat iflt = 12i;
idouble id = 13i;
ireal ir = 14i;
cfloat cf = 15 + 16i;
cdouble cd = 17 + 18i;
creal cr = 19 + 20i;
typeof(null) np = null;
c = c; c = c;
// CDB: ld basictypes_cdb* // CDB: ld basictypes_cdb*
// CDB: bp `basictypes_cdb.d:39` // CDB: bp `basictypes_cdb.d:41`
// CDB: g // CDB: g
// CHECK: !basictypes_cdb.basic_types // CHECK: !basictypes_cdb.basic_types
@ -66,6 +67,7 @@ int basic_types()
// CHECK: struct cfloat cf // CHECK: struct cfloat cf
// CHECK: struct cdouble cd // CHECK: struct cdouble cd
// CHECK: struct creal cr // CHECK: struct creal cr
// CHECK: void * np = 0x{{[0`]+}}
// CDB: ?? cf // CDB: ?? cf
// CHECK: +0x000 re : 15 // CHECK: +0x000 re : 15
// CHECK: +0x004 im : 16 // CHECK: +0x004 im : 16
@ -75,7 +77,7 @@ int basic_types()
// CDB: ?? cr // CDB: ?? cr
// CHECK: +0x000 re : 19 // CHECK: +0x000 re : 19
// CHECK: +0x008 im : 20 // CHECK: +0x008 im : 20
return 1; return 1;
} }
// CDB: q // CDB: q
// CHECK: quit // CHECK: quit