This revision was automatically updated to reflect the committed changes.
Closed by commit rG35870c442210: [lldb] Summary provider for char flexible 
array members (authored by labath).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113174/new/

https://reviews.llvm.org/D113174

Files:
  lldb/source/DataFormatters/FormatManager.cpp
  
lldb/test/API/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py
  lldb/test/API/lang/c/flexible-array-members/Makefile
  lldb/test/API/lang/c/flexible-array-members/TestCFlexibleArrayMembers.py
  lldb/test/API/lang/c/flexible-array-members/main.c

Index: lldb/test/API/lang/c/flexible-array-members/main.c
===================================================================
--- /dev/null
+++ lldb/test/API/lang/c/flexible-array-members/main.c
@@ -0,0 +1,37 @@
+#include <stdlib.h>
+#include <string.h>
+
+struct WithFlexChar {
+  int member;
+  char flexible[];
+};
+
+struct WithFlexSChar {
+  int member;
+  signed char flexible[];
+};
+
+struct WithFlexUChar {
+  int member;
+  unsigned char flexible[];
+};
+
+#define CONTENTS "contents"
+
+int main() {
+  struct WithFlexChar *c =
+      (struct WithFlexChar *)malloc(sizeof(int) + sizeof(CONTENTS));
+  c->member = 1;
+  strcpy(c->flexible, CONTENTS);
+
+  struct WithFlexSChar *sc =
+      (struct WithFlexSChar *)malloc(sizeof(int) + sizeof(CONTENTS));
+  sc->member = 1;
+  strcpy((char *)sc->flexible, CONTENTS);
+
+  struct WithFlexUChar *uc =
+      (struct WithFlexUChar *)malloc(sizeof(int) + sizeof(CONTENTS));
+  uc->member = 1;
+  strcpy((char *)uc->flexible, CONTENTS);
+  return 0; // break here
+}
Index: lldb/test/API/lang/c/flexible-array-members/TestCFlexibleArrayMembers.py
===================================================================
--- /dev/null
+++ lldb/test/API/lang/c/flexible-array-members/TestCFlexibleArrayMembers.py
@@ -0,0 +1,29 @@
+"""
+Tests C99's flexible array members.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestCase(TestBase):
+
+    mydir = TestBase.compute_mydir(__file__)
+
+    @no_debug_info_test
+    def test(self):
+        self.build()
+        lldbutil.run_to_source_breakpoint(self, "// break here",
+                lldb.SBFileSpec("main.c"))
+
+        self.expect_var_path("c->flexible", type="char[]", summary='"contents"')
+        self.expect_var_path("sc->flexible", type="signed char[]", summary='"contents"')
+        self.expect_var_path("uc->flexible", type="unsigned char[]", summary='"contents"')
+        # TODO: Make this work
+        self.expect("expr c->flexible", error=True,
+                substrs=["incomplete", "char[]"])
+        self.expect("expr sc->flexible", error=True,
+                substrs=["incomplete", "signed char[]"])
+        self.expect("expr uc->flexible", error=True,
+                substrs=["incomplete", "unsigned char[]"])
Index: lldb/test/API/lang/c/flexible-array-members/Makefile
===================================================================
--- /dev/null
+++ lldb/test/API/lang/c/flexible-array-members/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
Index: lldb/test/API/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py
===================================================================
--- lldb/test/API/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py
+++ lldb/test/API/functionalities/data-formatter/type_summary_list_arg/TestTypeSummaryListArg.py
@@ -25,8 +25,8 @@
         self.expect(
             'type summary list char',
             substrs=[
-                'char *',
-                'unsigned char'])
+                'char ?(\*|\[\])',
+                'char ?\[[0-9]+\]'])
 
         self.expect(
             'type summary list -w default',
@@ -40,5 +40,7 @@
             matching=False)
         self.expect(
             'type summary list -w system char',
-            substrs=['unsigned char *'],
+            substrs=[
+                'char ?(\*|\[\])',
+                'char ?\[[0-9]+\]'],
             matching=True)
Index: lldb/source/DataFormatters/FormatManager.cpp
===================================================================
--- lldb/source/DataFormatters/FormatManager.cpp
+++ lldb/source/DataFormatters/FormatManager.cpp
@@ -729,12 +729,8 @@
   TypeCategoryImpl::SharedPointer sys_category_sp =
       GetCategory(m_system_category_name);
 
-  sys_category_sp->GetTypeSummariesContainer()->Add(ConstString("char *"),
-                                                    string_format);
-  sys_category_sp->GetTypeSummariesContainer()->Add(
-      ConstString("unsigned char *"), string_format);
-  sys_category_sp->GetTypeSummariesContainer()->Add(
-      ConstString("signed char *"), string_format);
+  sys_category_sp->GetRegexTypeSummariesContainer()->Add(
+      RegularExpression(R"(^((un)?signed )?char ?(\*|\[\])$)"), string_format);
 
   sys_category_sp->GetRegexTypeSummariesContainer()->Add(
       std::move(any_size_char_arr), string_array_format);
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to