Skip to content

Commit 5989ac6

Browse files
committed
[lldb] Add type name mapping for DType
1 parent 54088cb commit 5989ac6

4 files changed

Lines changed: 66 additions & 1 deletion

File tree

lldb/source/Plugins/TypeSystem/D/DType.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,60 @@ llvm::Optional<uint64_t> DType::GetBitSize(llvm::Triple &target_triple) const {
178178
return llvm::None;
179179
}
180180
}
181+
182+
ConstString DType::GetName(DTypeKind kind)
183+
{
184+
switch(kind)
185+
{
186+
case eDTypeKindVoid:
187+
return ConstString("void");
188+
case eDTypeKindBool:
189+
return ConstString("bool");
190+
case eDTypeKindByte:
191+
return ConstString("byte");
192+
case eDTypeKindUByte:
193+
return ConstString("ubyte");
194+
case eDTypeKindShort:
195+
return ConstString("short");
196+
case eDTypeKindUShort:
197+
return ConstString("ushort");
198+
case eDTypeKindInt:
199+
return ConstString("int");
200+
case eDTypeKindUInt:
201+
return ConstString("uint");
202+
case eDTypeKindLong:
203+
return ConstString("long");
204+
case eDTypeKindULong:
205+
return ConstString("ulong");
206+
case eDTypeKindCent:
207+
return ConstString("cent");
208+
case eDTypeKindUCent:
209+
return ConstString("ucent");
210+
case eDTypeKindChar:
211+
return ConstString("char");
212+
case eDTypeKindWChar:
213+
return ConstString("wchar");
214+
case eDTypeKindDChar:
215+
return ConstString("dchar");
216+
case eDTypeKindFloat:
217+
return ConstString("float");
218+
case eDTypeKindDouble:
219+
return ConstString("double");
220+
case eDTypeKindReal:
221+
return ConstString("real");
222+
case eDTypeKindIFloat:
223+
return ConstString("ifloat");
224+
case eDTypeKindIDouble:
225+
return ConstString("idouble");
226+
case eDTypeKindIReal:
227+
return ConstString("ireal");
228+
case eDTypeKindCFloat:
229+
return ConstString("cfloat");
230+
case eDTypeKindCDouble:
231+
return ConstString("cdouble");
232+
case eDTypeKindCReal:
233+
return ConstString("creal");
234+
default:
235+
return ConstString();
236+
}
237+
}

lldb/source/Plugins/TypeSystem/D/DType.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class DType {
5656

5757
DTypeKind GetKind() { return m_kind; }
5858
const ConstString &GetName() const { return m_name; }
59+
static ConstString GetName(DTypeKind);
5960

6061
bool IsBuiltIn() const;
6162

lldb/source/Plugins/TypeSystem/D/TypeSystemD.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,12 @@ TypeSystemD::CreateBaseType(DTypeKind kind,
651651
return CompilerType(this, type);
652652
}
653653

654+
CompilerType
655+
TypeSystemD::CreateBaseType(DTypeKind kind) {
656+
DType *type = new DType(kind, DType::GetName(kind));
657+
return CompilerType(this, type);
658+
}
659+
654660
CompilerType
655661
TypeSystemD::GetBuiltinTypeForDWARFEncodingAndBitSize(uint32_t dw_ate, uint32_t bit_size)
656662
{
@@ -659,7 +665,7 @@ TypeSystemD::GetBuiltinTypeForDWARFEncodingAndBitSize(uint32_t dw_ate, uint32_t
659665
switch(dw_ate)
660666
{
661667
case DW_ATE_boolean:
662-
return CreateBaseType(eDTypeKindBool, ConstString("bool"));
668+
return CreateBaseType(eDTypeKindBool);
663669
default:
664670
break;
665671
}

lldb/source/Plugins/TypeSystem/D/TypeSystemD.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ class TypeSystemD : public TypeSystem {
342342
private:
343343
CompilerType CreateBaseType(DTypeKind kind,
344344
const lldb_private::ConstString &name);
345+
CompilerType CreateBaseType(DTypeKind kind);
345346

346347
CompilerType GetBuiltinTypeForDWARFEncodingAndBitSize(uint32_t dw_ate, uint32_t bit_size);
347348

0 commit comments

Comments
 (0)