[Lldb-commits] [lldb] [lldb][TypeSystemClang] Fix enum signedness in CompleteEnumType (PR #125203)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Fri Jan 31 03:43:24 PST 2025
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/125203
>From 620f30f73930a1a8b2edb298f67d555ff3b93e2c Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Fri, 31 Jan 2025 11:18:28 +0000
Subject: [PATCH 1/4] [lldb][TypeSystemClang] Fix enum signedness in
CompleteEnumType
---
.../SymbolFile/DWARF/DWARFASTParserClang.cpp | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 6602dd763ba693..359872c579f35e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1020,15 +1020,7 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc,
}
- if (TypeSystemClang::StartTagDeclarationDefinition(clang_type)) {
- if (def_die.HasChildren()) {
- bool is_signed = false;
- enumerator_clang_type.IsIntegerType(is_signed);
- ParseChildEnumerators(clang_type, is_signed,
- type_sp->GetByteSize(nullptr).value_or(0), def_die);
- }
- TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
- } else {
+ if (!CompleteEnumType(def_die, type_sp.get(), clang_type)) {
dwarf->GetObjectFile()->GetModule()->ReportError(
"DWARF DIE at {0:x16} named \"{1}\" was not able to start its "
"definition.\nPlease file a bug and attach the file at the "
@@ -2222,12 +2214,10 @@ bool DWARFASTParserClang::CompleteEnumType(const DWARFDIE &die,
lldb_private::Type *type,
const CompilerType &clang_type) {
if (TypeSystemClang::StartTagDeclarationDefinition(clang_type)) {
- if (die.HasChildren()) {
- bool is_signed = false;
- clang_type.IsIntegerType(is_signed);
- ParseChildEnumerators(clang_type, is_signed,
+ if (die.HasChildren())
+ ParseChildEnumerators(clang_type, clang_type.IsEnumerationIntegerTypeSigned(),
type->GetByteSize(nullptr).value_or(0), die);
- }
+
TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
}
return (bool)clang_type;
>From f72106fffe6dd20513134d35e6fbb9b31a06e9cf Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Fri, 31 Jan 2025 11:30:46 +0000
Subject: [PATCH 2/4] fixup! add assert
---
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 359872c579f35e..08fe4a29be8eb7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2213,6 +2213,8 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
bool DWARFASTParserClang::CompleteEnumType(const DWARFDIE &die,
lldb_private::Type *type,
const CompilerType &clang_type) {
+ assert (clang_type.IsEnumerationType());
+
if (TypeSystemClang::StartTagDeclarationDefinition(clang_type)) {
if (die.HasChildren())
ParseChildEnumerators(clang_type, clang_type.IsEnumerationIntegerTypeSigned(),
>From 23cd607c0c8130a783f80d94e98b7b89b70d45f0 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Fri, 31 Jan 2025 11:30:57 +0000
Subject: [PATCH 3/4] fixup! clang-format
---
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 08fe4a29be8eb7..ee99fd6f16cc44 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -2213,7 +2213,7 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
bool DWARFASTParserClang::CompleteEnumType(const DWARFDIE &die,
lldb_private::Type *type,
const CompilerType &clang_type) {
- assert (clang_type.IsEnumerationType());
+ assert(clang_type.IsEnumerationType());
if (TypeSystemClang::StartTagDeclarationDefinition(clang_type)) {
if (die.HasChildren())
>From f5b774a6260349778a92dcd852b76cccda1407c5 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Fri, 31 Jan 2025 11:42:40 +0000
Subject: [PATCH 4/4] fixup! clang-format
---
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index ee99fd6f16cc44..dca193fc11b552 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1019,7 +1019,6 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext &sc,
// Declaration DIE is inserted into the type map in ParseTypeFromDWARF
}
-
if (!CompleteEnumType(def_die, type_sp.get(), clang_type)) {
dwarf->GetObjectFile()->GetModule()->ReportError(
"DWARF DIE at {0:x16} named \"{1}\" was not able to start its "
@@ -2217,7 +2216,8 @@ bool DWARFASTParserClang::CompleteEnumType(const DWARFDIE &die,
if (TypeSystemClang::StartTagDeclarationDefinition(clang_type)) {
if (die.HasChildren())
- ParseChildEnumerators(clang_type, clang_type.IsEnumerationIntegerTypeSigned(),
+ ParseChildEnumerators(clang_type,
+ clang_type.IsEnumerationIntegerTypeSigned(),
type->GetByteSize(nullptr).value_or(0), die);
TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
More information about the lldb-commits
mailing list