@@ -149,11 +149,35 @@ static llvm::DIType dwarfBasicType(Type* type)
149
149
static llvm::DIType dwarfEnumType (Type *type)
150
150
{
151
151
llvm::Type *T = DtoType (type);
152
- Type *t = type->toBasetype ();
153
152
154
- // FIXME
153
+ assert (type->ty == Tenum && " only enums allowed for debug info in dwarfEnumType" );
154
+ TypeEnum *te = static_cast <TypeEnum *>(type);
155
+ llvm::SmallVector<llvm::Value *, 8 > subscripts;
156
+ for (ArrayIter<Dsymbol> it (te->sym ->members ); it.more (); it.next ())
157
+ {
158
+ EnumMember *em = it->isEnumMember ();
159
+ llvm::StringRef Name (em->toChars () /* em->ident->string*/ );
160
+ uint64_t Val = em->value ->toInteger ();
161
+ llvm::Value *Subscript = gIR ->dibuilder .createEnumerator (Name, Val);
162
+ subscripts.push_back (Subscript);
163
+ }
155
164
156
- return llvm::DIType (NULL );
165
+ llvm::StringRef Name = te->toChars ();
166
+ unsigned LineNumber = te->sym ->loc .linnum ;
167
+ llvm::DIFile File = DtoDwarfFile (te->sym ->loc );
168
+
169
+ return gIR ->dibuilder .createEnumerationType (
170
+ llvm::DIDescriptor (File),
171
+ Name,
172
+ File,
173
+ LineNumber,
174
+ getTypeBitSize (T), // size (bits)
175
+ getABITypeAlign (T)*8 , // align (bits)
176
+ gIR ->dibuilder .getOrCreateArray (subscripts) // subscripts
177
+ #if LDC_LLVM_VER >= 302
178
+ , dwarfTypeDescription_impl (te->sym ->memtype , NULL )
179
+ #endif
180
+ );
157
181
}
158
182
159
183
// ////////////////////////////////////////////////////////////////////////////////////////////////
@@ -463,12 +487,14 @@ static llvm::DIType dwarfTypeDescription_impl(Type* type, const char* c_name)
463
487
Type* t = type->toBasetype ();
464
488
if (t->ty == Tvoid)
465
489
return llvm::DIType (NULL );
466
- else if (t->ty == Tvector)
467
- return dwarfVectorType (type);
468
- else if (t->ty == Tenum)
469
- return dwarfEnumType (type);
470
490
else if (t->isintegral () || t->isfloating ())
491
+ {
492
+ if (t->ty == Tvector)
493
+ return dwarfVectorType (type);
494
+ if (type->ty == Tenum)
495
+ return dwarfEnumType (type);
471
496
return dwarfBasicType (type);
497
+ }
472
498
else if (t->ty == Tpointer)
473
499
return dwarfPointerType (type);
474
500
else if (t->ty == Tarray)
0 commit comments