Added support for zero-length arrays at the end
authorSean Callanan <scallanan@apple.com>
Mon, 22 Oct 2012 23:56:48 +0000 (23:56 +0000)
committerSean Callanan <scallanan@apple.com>
Mon, 22 Oct 2012 23:56:48 +0000 (23:56 +0000)
of structures, and added a testcase.

<rdar://problem/12551591>

llvm-svn: 166450

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/test/lang/c/struct_types/TestStructTypes.py
lldb/test/lang/c/struct_types/main.c

index 0f3ad3e..c58dd10 100644 (file)
@@ -4085,8 +4085,7 @@ SymbolFileDWARF::ParseChildArrayInfo
                     if (upper_bound > lower_bound)
                         num_elements = upper_bound - lower_bound + 1;
 
-                    if (num_elements > 0)
-                        element_orders.push_back (num_elements);
+                    element_orders.push_back (num_elements);
                 }
             }
             break;
index 1c28bbf..f393862 100644 (file)
@@ -55,6 +55,11 @@ class StructTypesTestCase(TestBase):
         self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
             substrs = [' resolved, hit count = 1'])
 
+        # The padding should be an array of size 0
+        self.expect("image lookup -t point_tag",
+            DATA_TYPES_DISPLAYED_CORRECTLY,
+            substrs = ['padding[0]'])
+
 
 if __name__ == '__main__':
     import atexit
index b3be185..174bfcc 100644 (file)
@@ -10,15 +10,15 @@ int main (int argc, char const *argv[])
 {
     struct point_tag {
         int x;
-        char padding[0];
         int y;
+        char padding[0];
     }; // Set break point at this line.
 
     struct rect_tag {
         struct point_tag bottom_left;
         struct point_tag top_right;
     };
-    struct point_tag pt = { 2, {}, 3 }; // This is the first executable statement.
-    struct rect_tag rect = {{1, {}, 2}, {3, {}, 4}};
+    struct point_tag pt = { 2, 3, {} }; // This is the first executable statement.
+    struct rect_tag rect = {{1, 2, {}}, {3, 4, {}}};
     return 0;
 }