[Lldb-commits] [lldb] eab5c2f - [LLDB] Fix crash when printing a struct with a static wchar_t member

Arthur Eubanks via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 11 11:05:44 PDT 2022


Author: Arthur Eubanks
Date: 2022-10-11T11:04:32-07:00
New Revision: eab5c2f94f5aae17c3fc513ee347ee9bc1d2bcae

URL: https://github.com/llvm/llvm-project/commit/eab5c2f94f5aae17c3fc513ee347ee9bc1d2bcae
DIFF: https://github.com/llvm/llvm-project/commit/eab5c2f94f5aae17c3fc513ee347ee9bc1d2bcae.diff

LOG: [LLDB] Fix crash when printing a struct with a static wchar_t member

Similar to D135170.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D135461

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 fabffbd323648..a29f762e10c14 100644
--- a/clang/lib/AST/StmtPrinter.cpp
+++ b/clang/lib/AST/StmtPrinter.cpp
@@ -1293,6 +1293,9 @@ void StmtPrinter::VisitIntegerLiteral(IntegerLiteral *Node) {
     break; // no suffix.
   case BuiltinType::UInt128:
     break; // no suffix.
+  case BuiltinType::WChar_S:
+  case BuiltinType::WChar_U:
+    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 91ed14ed48ab7..ed7cd2514ae84 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
@@ -42,6 +42,7 @@ def test(self):
         self.expect_expr("A::ulong_max == ulong_max", result_value="true")
         self.expect_expr("A::longlong_max == longlong_max", result_value="true")
         self.expect_expr("A::ulonglong_max == ulonglong_max", result_value="true")
+        self.expect_expr("A::wchar_max == wchar_max", result_value="true")
 
         self.expect_expr("A::char_min == char_min", result_value="true")
         self.expect_expr("A::schar_min == schar_min", result_value="true")
@@ -52,6 +53,7 @@ def test(self):
         self.expect_expr("A::ulong_min == ulong_min", result_value="true")
         self.expect_expr("A::longlong_min == longlong_min", result_value="true")
         self.expect_expr("A::ulonglong_min == ulonglong_min", result_value="true")
+        self.expect_expr("A::wchar_min == wchar_min", result_value="true")
 
         # Test an unscoped enum.
         self.expect_expr("A::enum_val", result_value="enum_case2")

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 09ab9e6698132..4cd4933275ae4 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
@@ -36,6 +36,7 @@ struct A {
   const static auto longlong_max = std::numeric_limits<long long>::max();
   const static auto ulonglong_max =
       std::numeric_limits<unsigned long long>::max();
+  const static auto wchar_max = std::numeric_limits<wchar_t>::max();
 
   const static auto char_min = std::numeric_limits<char>::min();
   const static auto schar_min = std::numeric_limits<signed char>::min();
@@ -47,6 +48,7 @@ struct A {
   const static auto longlong_min = std::numeric_limits<long long>::min();
   const static auto ulonglong_min =
       std::numeric_limits<unsigned long long>::min();
+  const static auto wchar_min = std::numeric_limits<wchar_t>::min();
 
   const static Enum enum_val = enum_case2;
   const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
@@ -93,6 +95,7 @@ int main() {
   auto ulong_max = A::ulong_max;
   auto longlong_max = A::longlong_max;
   auto ulonglong_max = A::ulonglong_max;
+  auto wchar_max = A::wchar_max;
 
   auto char_min = A::char_min;
   auto schar_min = A::schar_min;
@@ -103,6 +106,7 @@ int main() {
   auto ulong_min = A::ulong_min;
   auto longlong_min = A::longlong_min;
   auto ulonglong_min = A::ulonglong_min;
+  auto wchar_min = A::wchar_min;
 
   int member_copy = ClassWithOnlyConstStatic::member;
 


        


More information about the lldb-commits mailing list