[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
This commit is contained in:
David Spickett 2022-10-05 11:30:05 +00:00
parent 8307f6c854
commit 5a9e213058
3 changed files with 5 additions and 10 deletions

View File

@ -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.

View File

@ -32,11 +32,6 @@ class TestCase(TestBase):
# 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 @@ class TestCase(TestBase):
self.expect_expr("const int *i = &A::int_val_with_address; *i",
result_value="2")
# 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.
@expectedFailureAll(debug_info=["dsym"])

View File

@ -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;