[Lldb-commits] [PATCH] D135170: [LLDB] Fix crash when printing a struct with a static signed char member

David Spickett via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 7 02:11:25 PDT 2022

This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5a9e21305803: [LLDB] Fix crash when printing a struct with a static signed char member (authored by DavidSpickett).

  rG LLVM Github Monorepo




Index: lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
--- lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -79,13 +79,8 @@
-struct StaticBoolStruct {
-  static const bool value = false;
 int main() {
   A a;
-  StaticBoolStruct sbs;
   auto char_max = A::char_max;
   auto uchar_max = A::uchar_max;
Index: lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
--- lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -32,11 +32,6 @@
         # Test a bool member.
         self.expect_expr("A::bool_val", result_value="true")
-        # Test a bool member when printing the struct it is a member of.
-        # TODO: replace this with printing struct A, once doing so doesn't crash lldb.
-        self.expect("image lookup -t StaticBoolStruct",
-                    substrs=["static const bool value = false;"])
         # Test that minimum and maximum values for each data type are right.
         self.expect_expr("A::char_max == char_max", result_value="true")
         self.expect_expr("A::uchar_max == uchar_max", result_value="true")
@@ -88,6 +83,10 @@
         self.expect_expr("const int *i = &A::int_val_with_address; *i",
+        # Printing the whole type takes a slightly different code path. Check that
+        # it does not crash.
+        self.expect("image lookup -t A")
     # dsymutil strips the debug info for classes that only have const static
     # data members without a definition namespace scope.
Index: clang/lib/AST/StmtPrinter.cpp
--- clang/lib/AST/StmtPrinter.cpp
+++ clang/lib/AST/StmtPrinter.cpp
@@ -1280,6 +1280,7 @@
   case BuiltinType::Char_S:
   case BuiltinType::Char_U:    OS << "i8"; break;
   case BuiltinType::UChar:     OS << "Ui8"; break;
+  case BuiltinType::SChar:     OS << "i8"; break;
   case BuiltinType::Short:     OS << "i16"; break;
   case BuiltinType::UShort:    OS << "Ui16"; break;
   case BuiltinType::Int:       break; // no suffix.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135170.466009.patch
Type: text/x-patch
Size: 2495 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20221007/197f93d9/attachment.bin>

More information about the lldb-commits mailing list