[clang] 5a9e213 - [LLDB] Fix crash when printing a struct with a static signed char member
David Spickett via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 7 02:11:31 PDT 2022
Author: David Spickett
Date: 2022-10-07T09:11:15Z
New Revision: 5a9e21305803336dc359f72014849845b1a7e173
URL: https://github.com/llvm/llvm-project/commit/5a9e21305803336dc359f72014849845b1a7e173
DIFF: https://github.com/llvm/llvm-project/commit/5a9e21305803336dc359f72014849845b1a7e173.diff
LOG: [LLDB] Fix crash when printing a struct with a static signed char member
As with static bool for whatever reason printing them on their own
worked fine but wasn't handled when you printed the whole type.
I don't see a good way to test this from clang's side so our existing
tests will have to do.
We can now print all of the struct "A", so there's no need for a separate
one for static bool testing. I've not checked the output, just that it
succeeds. This saves us having to handle different min/max between systems.
Depends on D135169
Reviewed By: aeubanks, shafik
Differential Revision: https://reviews.llvm.org/D135170
Added:
Modified:
clang/lib/AST/StmtPrinter.cpp
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/StmtPrinter.cpp b/clang/lib/AST/StmtPrinter.cpp
index 03b71a7ec9416..fabffbd323648 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1280,6 +1280,7 @@ void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
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.
diff --git a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
index 0482007d48147..5252247191383 100644
--- a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
+++ b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
@@ -32,11 +32,6 @@ def test(self):
# 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 @@ def test(self):
self.expect_expr("const int *i = &A::int_val_with_address; *i",
result_value="2")
+ # Printing the whole type takes a slightly
diff erent 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.
@expectedFailureAll(debug_info=["dsym"])
diff --git a/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp b/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
index d078076b99dc8..977e12295760a 100644
--- a/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ b/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -79,13 +79,8 @@ struct ClassWithEnumAlias {
ScopedEnum::scoped_enum_case1;
};
-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;
More information about the cfe-commits
mailing list