Skip to content

Commit 9f169e6

Browse files
committed
[lldb] Add type name mapping for DType
1 parent 26d89d6 commit 9f169e6

File tree

4 files changed

+68
-1
lines changed

4 files changed

+68
-1
lines changed

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

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

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
@@ -666,6 +666,12 @@ TypeSystemD::CreateBaseType(DTypeKind kind,
666666
return CompilerType(this, type);
667667
}
668668

669+
CompilerType
670+
TypeSystemD::CreateBaseType(DTypeKind kind) {
671+
DType *type = new DType(kind, DType::GetName(kind));
672+
return CompilerType(this, type);
673+
}
674+
669675
CompilerType
670676
TypeSystemD::GetBuiltinTypeForDWARFEncodingAndBitSize(uint32_t dw_ate, uint32_t bit_size)
671677
{
@@ -674,7 +680,7 @@ TypeSystemD::GetBuiltinTypeForDWARFEncodingAndBitSize(uint32_t dw_ate, uint32_t
674680
switch(dw_ate)
675681
{
676682
case DW_ATE_boolean:
677-
return CreateBaseType(eDTypeKindBool, ConstString("bool"));
683+
return CreateBaseType(eDTypeKindBool);
678684
default:
679685
break;
680686
}

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)