[Lldb-commits] [lldb] [LLDB][NativePDB] Consolidate simple types (PR #163209)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 14 11:19:47 PDT 2025
https://github.com/Nerixyz updated https://github.com/llvm/llvm-project/pull/163209
>From cc32535a5a7c0ec28d30e7f029af06b61d78beab Mon Sep 17 00:00:00 2001
From: Nerixyz <nerixdev at outlook.de>
Date: Mon, 13 Oct 2025 16:20:19 +0200
Subject: [PATCH 1/2] [LLDB][NativePDB] Consolidate simple types
---
.../Plugins/SymbolFile/NativePDB/PdbUtil.cpp | 28 ++++++++-
.../NativePDB/SymbolFileNativePDB.cpp | 62 ++++++++++++++-----
.../SymbolFile/NativePDB/simple-types.cpp | 29 ++++++---
3 files changed, 97 insertions(+), 22 deletions(-)
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
index 888bd89a72625..f84508478ae6c 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
@@ -946,17 +946,21 @@ lldb_private::npdb::GetCompilerTypeForSimpleKind(SimpleTypeKind kind) {
case SimpleTypeKind::Complex64:
return lldb::eBasicTypeDoubleComplex;
case SimpleTypeKind::Complex32:
+ case SimpleTypeKind::Complex32PartialPrecision:
return lldb::eBasicTypeFloatComplex;
- case SimpleTypeKind::Float128:
case SimpleTypeKind::Float80:
return lldb::eBasicTypeLongDouble;
+ case SimpleTypeKind::Float128:
+ return lldb::eBasicTypeFloat128;
case SimpleTypeKind::Float64:
return lldb::eBasicTypeDouble;
case SimpleTypeKind::Float32:
+ case SimpleTypeKind::Float32PartialPrecision:
return lldb::eBasicTypeFloat;
case SimpleTypeKind::Float16:
return lldb::eBasicTypeHalf;
case SimpleTypeKind::Int128:
+ case SimpleTypeKind::Int128Oct:
return lldb::eBasicTypeInt128;
case SimpleTypeKind::Int64:
case SimpleTypeKind::Int64Quad:
@@ -967,6 +971,7 @@ lldb_private::npdb::GetCompilerTypeForSimpleKind(SimpleTypeKind kind) {
case SimpleTypeKind::Int16Short:
return lldb::eBasicTypeShort;
case SimpleTypeKind::UInt128:
+ case SimpleTypeKind::UInt128Oct:
return lldb::eBasicTypeUnsignedInt128;
case SimpleTypeKind::UInt64:
case SimpleTypeKind::UInt64Quad:
@@ -985,6 +990,15 @@ lldb_private::npdb::GetCompilerTypeForSimpleKind(SimpleTypeKind kind) {
return lldb::eBasicTypeVoid;
case SimpleTypeKind::WideCharacter:
return lldb::eBasicTypeWChar;
+
+ case SimpleTypeKind::None:
+ case SimpleTypeKind::NotTranslated:
+
+ // unsupported
+ case SimpleTypeKind::Float48:
+ case SimpleTypeKind::Complex16:
+ case SimpleTypeKind::Complex48:
+ case SimpleTypeKind::Complex128:
default:
return lldb::eBasicTypeInvalid;
}
@@ -993,8 +1007,11 @@ lldb_private::npdb::GetCompilerTypeForSimpleKind(SimpleTypeKind kind) {
size_t lldb_private::npdb::GetTypeSizeForSimpleKind(SimpleTypeKind kind) {
switch (kind) {
case SimpleTypeKind::Boolean128:
+ case SimpleTypeKind::Complex128:
case SimpleTypeKind::Int128:
+ case SimpleTypeKind::Int128Oct:
case SimpleTypeKind::UInt128:
+ case SimpleTypeKind::UInt128Oct:
case SimpleTypeKind::Float128:
return 16;
case SimpleTypeKind::Complex80:
@@ -1008,10 +1025,15 @@ size_t lldb_private::npdb::GetTypeSizeForSimpleKind(SimpleTypeKind kind) {
case SimpleTypeKind::Int64:
case SimpleTypeKind::Int64Quad:
return 8;
+ case SimpleTypeKind::Complex48:
+ case SimpleTypeKind::Float48:
+ return 6;
case SimpleTypeKind::Boolean32:
case SimpleTypeKind::Character32:
case SimpleTypeKind::Complex32:
+ case SimpleTypeKind::Complex32PartialPrecision:
case SimpleTypeKind::Float32:
+ case SimpleTypeKind::Float32PartialPrecision:
case SimpleTypeKind::Int32:
case SimpleTypeKind::Int32Long:
case SimpleTypeKind::UInt32Long:
@@ -1020,6 +1042,7 @@ size_t lldb_private::npdb::GetTypeSizeForSimpleKind(SimpleTypeKind kind) {
return 4;
case SimpleTypeKind::Boolean16:
case SimpleTypeKind::Character16:
+ case SimpleTypeKind::Complex16:
case SimpleTypeKind::Float16:
case SimpleTypeKind::Int16:
case SimpleTypeKind::Int16Short:
@@ -1035,7 +1058,10 @@ size_t lldb_private::npdb::GetTypeSizeForSimpleKind(SimpleTypeKind kind) {
case SimpleTypeKind::SByte:
case SimpleTypeKind::Character8:
return 1;
+
case SimpleTypeKind::Void:
+ case SimpleTypeKind::None:
+ case SimpleTypeKind::NotTranslated:
default:
return 0;
}
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 7e275f196d10e..b202b19b65ee1 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -152,14 +152,24 @@ static bool IsFunctionEpilogue(const CompilandIndexItem &cci,
return false;
}
+// See llvm::codeview::TypeIndex::simpleTypeName as well as strForPrimitiveTi
+// from the original pdbdump:
+// https://github.com/microsoft/microsoft-pdb/blob/805655a28bd8198004be2ac27e6e0290121a5e89/pdbdump/pdbdump.cpp#L1896-L1974
+//
+// For 64bit integers we use "long long" like DIA instead of "__int64".
static llvm::StringRef GetSimpleTypeName(SimpleTypeKind kind) {
switch (kind) {
case SimpleTypeKind::Boolean128:
- case SimpleTypeKind::Boolean16:
- case SimpleTypeKind::Boolean32:
+ return "__bool128";
case SimpleTypeKind::Boolean64:
+ return "__bool64";
+ case SimpleTypeKind::Boolean32:
+ return "__bool32";
+ case SimpleTypeKind::Boolean16:
+ return "__bool16";
case SimpleTypeKind::Boolean8:
return "bool";
+
case SimpleTypeKind::Byte:
case SimpleTypeKind::UnsignedCharacter:
return "unsigned char";
@@ -168,54 +178,78 @@ static llvm::StringRef GetSimpleTypeName(SimpleTypeKind kind) {
case SimpleTypeKind::SignedCharacter:
case SimpleTypeKind::SByte:
return "signed char";
- case SimpleTypeKind::Character16:
- return "char16_t";
case SimpleTypeKind::Character32:
return "char32_t";
+ case SimpleTypeKind::Character16:
+ return "char16_t";
case SimpleTypeKind::Character8:
return "char8_t";
+
+ case SimpleTypeKind::Complex128:
+ return "_Complex __float128";
case SimpleTypeKind::Complex80:
+ return "_Complex long double";
case SimpleTypeKind::Complex64:
+ return "_Complex double";
+ case SimpleTypeKind::Complex48:
+ return "_Complex __float48";
case SimpleTypeKind::Complex32:
- return "complex";
+ case SimpleTypeKind::Complex32PartialPrecision:
+ return "_Complex float";
+ case SimpleTypeKind::Complex16:
+ return "_Complex _Float16";
+
case SimpleTypeKind::Float128:
+ return "__float128";
case SimpleTypeKind::Float80:
return "long double";
case SimpleTypeKind::Float64:
return "double";
+ case SimpleTypeKind::Float48:
+ return "__float48";
case SimpleTypeKind::Float32:
+ case SimpleTypeKind::Float32PartialPrecision:
return "float";
case SimpleTypeKind::Float16:
- return "single";
+ return "_Float16";
+
+ case SimpleTypeKind::Int128Oct:
case SimpleTypeKind::Int128:
return "__int128";
case SimpleTypeKind::Int64:
case SimpleTypeKind::Int64Quad:
- return "int64_t";
+ return "long long";
+ case SimpleTypeKind::Int32Long:
+ return "long";
case SimpleTypeKind::Int32:
return "int";
case SimpleTypeKind::Int16:
+ case SimpleTypeKind::Int16Short:
return "short";
+
+ case SimpleTypeKind::UInt128Oct:
case SimpleTypeKind::UInt128:
return "unsigned __int128";
case SimpleTypeKind::UInt64:
case SimpleTypeKind::UInt64Quad:
- return "uint64_t";
- case SimpleTypeKind::HResult:
- return "HRESULT";
+ return "unsigned long long";
case SimpleTypeKind::UInt32:
return "unsigned";
case SimpleTypeKind::UInt16:
case SimpleTypeKind::UInt16Short:
return "unsigned short";
- case SimpleTypeKind::Int32Long:
- return "long";
case SimpleTypeKind::UInt32Long:
return "unsigned long";
+
+ case SimpleTypeKind::HResult:
+ return "HRESULT";
case SimpleTypeKind::Void:
return "void";
case SimpleTypeKind::WideCharacter:
return "wchar_t";
+
+ case SimpleTypeKind::None:
+ case SimpleTypeKind::NotTranslated:
default:
return "";
}
@@ -598,8 +632,8 @@ lldb::TypeSP SymbolFileNativePDB::CreateSimpleType(TypeIndex ti,
uint64_t uid = toOpaqueUid(PdbTypeSymId(ti, false));
if (ti == TypeIndex::NullptrT()) {
Declaration decl;
- return MakeType(uid, ConstString("std::nullptr_t"), 0, nullptr,
- LLDB_INVALID_UID, Type::eEncodingIsUID, decl, ct,
+ return MakeType(uid, ConstString("decltype(nullptr)"), std::nullopt,
+ nullptr, LLDB_INVALID_UID, Type::eEncodingIsUID, decl, ct,
Type::ResolveState::Full);
}
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/simple-types.cpp b/lldb/test/Shell/SymbolFile/NativePDB/simple-types.cpp
index 403cd2905e0e9..3781194e2e992 100644
--- a/lldb/test/Shell/SymbolFile/NativePDB/simple-types.cpp
+++ b/lldb/test/Shell/SymbolFile/NativePDB/simple-types.cpp
@@ -58,20 +58,28 @@ int main() {
MyStruct my_struct;
+ _Float16 f16;
+
+ _Complex float cf;
+ _Complex double cd;
+
+ __int128 i128;
+ unsigned __int128 ui128;
+
decltype(nullptr) np;
}
-// CHECK-DAG: Type{{.*}} , name = "std::nullptr_t", size = 0, compiler_type = 0x{{[0-9a-f]+}} nullptr_t
+// CHECK-DAG: Type{{.*}} , name = "decltype(nullptr)", compiler_type = 0x{{[0-9a-f]+}} nullptr_t
// CHECK-DAG: Type{{.*}} , name = "bool", size = 1, compiler_type = 0x{{[0-9a-f]+}} _Bool
// CHECK-DAG: Type{{.*}} , name = "char", size = 1, compiler_type = 0x{{[0-9a-f]+}} char
// CHECK-DAG: Type{{.*}} , name = "unsigned char", size = 1, compiler_type = 0x{{[0-9a-f]+}} unsigned char
// CHECK-DAG: Type{{.*}} , name = "char8_t", size = 1, compiler_type = 0x{{[0-9a-f]+}} char8_t
-// CHECK-DAG: Type{{.*}} , size = 2, compiler_type = 0x{{[0-9a-f]+}} short
-// CHECK-DAG: Type{{.*}} , name = "const volatile ", size = 2, compiler_type = 0x{{[0-9a-f]+}} const volatile short
-// CHECK-DAG: Type{{.*}} , name = "const ", size = 2, compiler_type = 0x{{[0-9a-f]+}} const short
-// CHECK-DAG: Type{{.*}} , name = "volatile ", size = 2, compiler_type = 0x{{[0-9a-f]+}} volatile short
+// CHECK-DAG: Type{{.*}} , name = "short", size = 2, compiler_type = 0x{{[0-9a-f]+}} short
+// CHECK-DAG: Type{{.*}} , name = "const volatile short", size = 2, compiler_type = 0x{{[0-9a-f]+}} const volatile short
+// CHECK-DAG: Type{{.*}} , name = "const short", size = 2, compiler_type = 0x{{[0-9a-f]+}} const short
+// CHECK-DAG: Type{{.*}} , name = "volatile short", size = 2, compiler_type = 0x{{[0-9a-f]+}} volatile short
// CHECK-DAG: Type{{.*}} , name = "unsigned short", size = 2, compiler_type = 0x{{[0-9a-f]+}} unsigned short
// CHECK-DAG: Type{{.*}} , name = "wchar_t", size = 2, compiler_type = 0x{{[0-9a-f]+}} wchar_t
@@ -83,12 +91,19 @@ int main() {
// CHECK-DAG: Type{{.*}} , name = "unsigned long", size = 4, compiler_type = 0x{{[0-9a-f]+}} unsigned long
// CHECK-DAG: Type{{.*}} , name = "char32_t", size = 4, compiler_type = 0x{{[0-9a-f]+}} char32_t
-// CHECK-DAG: Type{{.*}} , name = "int64_t", size = 8, compiler_type = 0x{{[0-9a-f]+}} long long
-// CHECK-DAG: Type{{.*}} , name = "uint64_t", size = 8, compiler_type = 0x{{[0-9a-f]+}} unsigned long long
+// CHECK-DAG: Type{{.*}} , name = "long long", size = 8, compiler_type = 0x{{[0-9a-f]+}} long long
+// CHECK-DAG: Type{{.*}} , name = "unsigned long long", size = 8, compiler_type = 0x{{[0-9a-f]+}} unsigned long long
+// CHECK-DAG: Type{{.*}} , name = "__int128", size = 16, compiler_type = 0x{{[0-9a-f]+}} __int128
+// CHECK-DAG: Type{{.*}} , name = "unsigned __int128", size = 16, compiler_type = 0x{{[0-9a-f]+}} unsigned __int128
+
+// CHECK-DAG: Type{{.*}} , name = "_Float16", size = 2, compiler_type = 0x{{[0-9a-f]+}} __fp16
// CHECK-DAG: Type{{.*}} , name = "float", size = 4, compiler_type = 0x{{[0-9a-f]+}} float
// CHECK-DAG: Type{{.*}} , name = "const float", size = 4, compiler_type = 0x{{[0-9a-f]+}} const float
+// CHECK-DAG: Type{{.*}} , name = "_Complex float", size = 4, compiler_type = 0x{{[0-9a-f]+}} _Complex float
+// CHECK-DAG: Type{{.*}} , name = "_Complex double", size = 8, compiler_type = 0x{{[0-9a-f]+}} _Complex double
+
// CHECK-DAG: Type{{.*}} , name = "ReturnedStruct1", size = 1, decl = simple-types.cpp:21, compiler_type = 0x{{[0-9a-f]+}} struct ReturnedStruct1 {
// CHECK-DAG: Type{{.*}} , name = "ReturnedStruct2", size = 1, decl = simple-types.cpp:22, compiler_type = 0x{{[0-9a-f]+}} struct ReturnedStruct2 {
// CHECK-DAG: Type{{.*}} , name = "MyStruct", size = 1, decl = simple-types.cpp:24, compiler_type = 0x{{[0-9a-f]+}} struct MyStruct {
>From 361860de9fa1975a1585a1cf3b8f0eceba5a2102 Mon Sep 17 00:00:00 2001
From: Nerixyz <nerixdev at outlook.de>
Date: Tue, 14 Oct 2025 20:19:31 +0200
Subject: [PATCH 2/2] fix: unreachable code warnings
---
lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp | 9 ++++-----
.../Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp | 2 +-
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
index f84508478ae6c..20a3f268dd316 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
@@ -991,17 +991,16 @@ lldb_private::npdb::GetCompilerTypeForSimpleKind(SimpleTypeKind kind) {
case SimpleTypeKind::WideCharacter:
return lldb::eBasicTypeWChar;
- case SimpleTypeKind::None:
- case SimpleTypeKind::NotTranslated:
-
// unsupported
case SimpleTypeKind::Float48:
case SimpleTypeKind::Complex16:
case SimpleTypeKind::Complex48:
case SimpleTypeKind::Complex128:
- default:
+ case SimpleTypeKind::NotTranslated:
+ case SimpleTypeKind::None:
return lldb::eBasicTypeInvalid;
}
+ return lldb::eBasicTypeInvalid;
}
size_t lldb_private::npdb::GetTypeSizeForSimpleKind(SimpleTypeKind kind) {
@@ -1062,9 +1061,9 @@ size_t lldb_private::npdb::GetTypeSizeForSimpleKind(SimpleTypeKind kind) {
case SimpleTypeKind::Void:
case SimpleTypeKind::None:
case SimpleTypeKind::NotTranslated:
- default:
return 0;
}
+ return 0;
}
PdbTypeSymId lldb_private::npdb::GetBestPossibleDecl(PdbTypeSymId id,
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index b202b19b65ee1..ecd3188b3d564 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -250,9 +250,9 @@ static llvm::StringRef GetSimpleTypeName(SimpleTypeKind kind) {
case SimpleTypeKind::None:
case SimpleTypeKind::NotTranslated:
- default:
return "";
}
+ return "";
}
static bool IsClassRecord(TypeLeafKind kind) {
More information about the lldb-commits
mailing list