[libcxx-commits] [libcxx] [libc++] Fix gdb pretty printer for strings (PR #176882)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 3 06:09:12 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp b/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
index 638137f8d..686d72f9c 100644
--- a/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
+++ b/libcxx/test/libcxx/gdb/gdb_pretty_printer_test.sh.cpp
@@ -174,14 +174,11 @@ template <typename T> class UncompressibleAllocator : public std::allocator<T> {
 
 // Helper function to check pretty printing of short strings returned by
 // debugger-called functions.
-std::string return_short_string() {
-  return "abc";
-}
+std::string return_short_string() { return "abc"; }
 
 // Helper function to check pretty printing of long strings returned by
 // debugger-called functions.
-std::basic_string<char, std::char_traits<char>, UncompressibleAllocator<char>>
-return_long_string() {
+std::basic_string<char, std::char_traits<char>, UncompressibleAllocator<char>> return_long_string() {
   return "this is a string that is too long to fit in the string object";
 }
 
@@ -199,9 +196,9 @@ void string_test() {
   // when stepping out of a function differently from string variables. These
   // two tests check that pretty printing works also for this case.
   CompareExpressionPrettyPrintToChars("return_short_string()", "\"abc\"");
-  CompareExpressionPrettyPrintToChars("return_long_string()",
-      "\"this is a string that is too long to fit in the string object\"");
-  }
+  CompareExpressionPrettyPrintToChars(
+      "return_long_string()", "\"this is a string that is too long to fit in the string object\"");
+}
 
 namespace a_namespace {
 // To test name-lookup in the presence of using inside a namespace. Inside this
@@ -231,13 +228,9 @@ void string_view_test() {
 }
 }
 
-std::u16string return_short_u16string() {
-  return u"a";
-}
+std::u16string return_short_u16string() { return u"a"; }
 
-std::u16string return_long_u16string() {
-  return u"this is a string that is too long to fit in the string object";
-}
+std::u16string return_long_u16string() { return u"this is a string that is too long to fit in the string object"; }
 
 void u16string_test() {
   std::u16string test0 = u"Hello World";
@@ -253,17 +246,13 @@ void u16string_test() {
   // when stepping out of a function differently from string variables. These
   // two tests check that pretty printing works also for this case.
   CompareExpressionPrettyPrintToChars("return_short_u16string()", "u\"a\"");
-  CompareExpressionPrettyPrintToChars("return_long_u16string()",
-      "u\"this is a string that is too long to fit in the string object\"");
+  CompareExpressionPrettyPrintToChars(
+      "return_long_u16string()", "u\"this is a string that is too long to fit in the string object\"");
 }
 
-std::u32string return_short_u32string() {
-  return U"a";
-}
+std::u32string return_short_u32string() { return U"a"; }
 
-std::u32string return_long_u32string() {
-  return U"this is a string that is too long to fit in the string object";
-}
+std::u32string return_long_u32string() { return U"this is a string that is too long to fit in the string object"; }
 
 void u32string_test() {
   std::u32string test0 = U"Hello World";
@@ -281,8 +270,8 @@ void u32string_test() {
   // when stepping out of a function differently from string variables. These
   // two tests check that pretty printing works also for this case.
   CompareExpressionPrettyPrintToChars("return_short_u32string()", "U\"a\"");
-  CompareExpressionPrettyPrintToChars("return_long_u32string()",
-      "U\"this is a string that is too long to fit in the string object\"");
+  CompareExpressionPrettyPrintToChars(
+      "return_long_u32string()", "U\"this is a string that is too long to fit in the string object\"");
 }
 
 void tuple_test() {

``````````

</details>


https://github.com/llvm/llvm-project/pull/176882


More information about the libcxx-commits mailing list