Author: Raphael Isemann
Date: 2021-08-30T16:38:13+02:00
New Revision: 2ce889fa4e5cab75fc65d03a4dfae52784d57db9

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

LOG: [lldb][NFC] Add size tests for empty records with alignment and with empty 
members

This came up during the Windows bot failure discussing after D105471 . See
also 3d9a9fa6911a5228ce799a7c639e94d322678934 .

Added: 
    

Modified: 
    lldb/test/API/lang/c/sizeof/TestCSizeof.py
    lldb/test/API/lang/c/sizeof/main.c
    lldb/test/API/lang/cpp/sizeof/TestCPPSizeof.py
    lldb/test/API/lang/cpp/sizeof/main.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/lang/c/sizeof/TestCSizeof.py 
b/lldb/test/API/lang/c/sizeof/TestCSizeof.py
index 5bcbc42e3dfcf..67766833623db 100644
--- a/lldb/test/API/lang/c/sizeof/TestCSizeof.py
+++ b/lldb/test/API/lang/c/sizeof/TestCSizeof.py
@@ -14,5 +14,6 @@ def test(self):
         # Empty structs are not allowed in C, but Clang/GCC allow them and
         # give them a size of 0.
         self.expect_expr("sizeof(Empty) == sizeof_empty", result_value="true")
+        self.expect_expr("sizeof(EmptyMember) == sizeof_empty_member", 
result_value="true")
         self.expect_expr("sizeof(SingleMember) == sizeof_single", 
result_value="true")
         self.expect_expr("sizeof(PaddingMember) == sizeof_padding", 
result_value="true")

diff  --git a/lldb/test/API/lang/c/sizeof/main.c 
b/lldb/test/API/lang/c/sizeof/main.c
index 08bf906edb4af..fa7bd2d46b1a9 100644
--- a/lldb/test/API/lang/c/sizeof/main.c
+++ b/lldb/test/API/lang/c/sizeof/main.c
@@ -1,4 +1,7 @@
 struct Empty {};
+struct EmptyMember {
+  char i[0];
+};
 struct SingleMember {
   int i;
 };
@@ -9,13 +12,15 @@ struct PaddingMember {
 };
 
 const unsigned sizeof_empty = sizeof(struct Empty);
+const unsigned sizeof_empty_member = sizeof(struct EmptyMember);
 const unsigned sizeof_single = sizeof(struct SingleMember);
 const unsigned sizeof_padding = sizeof(struct PaddingMember);
 
 int main() {
   struct Empty empty;
+  struct EmptyMember empty_member;
   struct SingleMember single;
   struct PaddingMember padding;
   // Make sure globals are used.
-  return sizeof_empty + sizeof_single + sizeof_padding;
+  return sizeof_empty + sizeof_empty_member + sizeof_single + sizeof_padding;
 }

diff  --git a/lldb/test/API/lang/cpp/sizeof/TestCPPSizeof.py 
b/lldb/test/API/lang/cpp/sizeof/TestCPPSizeof.py
index c6b54de349470..e7f4623ee91f2 100644
--- a/lldb/test/API/lang/cpp/sizeof/TestCPPSizeof.py
+++ b/lldb/test/API/lang/cpp/sizeof/TestCPPSizeof.py
@@ -14,6 +14,10 @@ def test(self):
         # Empty structs/classes have size 1 in C++.
         self.expect_expr("sizeof(Empty) == sizeof_empty", result_value="true")
         self.expect_expr("sizeof(EmptyClass) == sizeof_empty_class", 
result_value="true")
+        self.expect_expr("sizeof(EmptyClassAligned) == 
sizeof_empty_class_aligned",
+                         result_value="true")
+        self.expect_expr("sizeof(ClassEmptyMember) == 
sizeof_class_empty_member",
+                         result_value="true")
         self.expect_expr("sizeof(SingleMember) == sizeof_single", 
result_value="true")
         self.expect_expr("sizeof(SingleMemberClass) == sizeof_single_class", 
result_value="true")
         self.expect_expr("sizeof(PaddingMember) == sizeof_padding", 
result_value="true")

diff  --git a/lldb/test/API/lang/cpp/sizeof/main.cpp 
b/lldb/test/API/lang/cpp/sizeof/main.cpp
index 6c4da06cbef85..4a7a89a1307fd 100644
--- a/lldb/test/API/lang/cpp/sizeof/main.cpp
+++ b/lldb/test/API/lang/cpp/sizeof/main.cpp
@@ -1,5 +1,9 @@
 struct Empty {};
 class EmptyClass {};
+class alignas(4) EmptyClassAligned {};
+class ClassEmptyMember {
+  int i[0];
+};
 
 struct SingleMember {
   int i;
@@ -19,6 +23,8 @@ class PaddingMemberClass {
 
 const unsigned sizeof_empty = sizeof(Empty);
 const unsigned sizeof_empty_class = sizeof(EmptyClass);
+const unsigned sizeof_empty_class_aligned = sizeof(EmptyClassAligned);
+const unsigned sizeof_class_empty_member = sizeof(ClassEmptyMember);
 const unsigned sizeof_single = sizeof(SingleMember);
 const unsigned sizeof_single_class = sizeof(SingleMemberClass);
 const unsigned sizeof_padding = sizeof(PaddingMember);
@@ -27,11 +33,14 @@ const unsigned sizeof_padding_class = 
sizeof(PaddingMemberClass);
 int main() {
   Empty empty;
   EmptyClass empty_class;
+  EmptyClassAligned empty_class_aligned;
+  ClassEmptyMember class_empty_member;
   SingleMember single;
   SingleMemberClass single_class;
   PaddingMember padding;
   PaddingMemberClass padding_class;
   // Make sure globals are used.
-  return sizeof_empty + sizeof_empty_class + sizeof_single +
-    sizeof_single_class + sizeof_padding + sizeof_padding_class;
+  return sizeof_empty + sizeof_empty_class + sizeof_class_empty_member +
+         sizeof_single + +sizeof_empty_class_aligned + sizeof_single_class +
+         sizeof_padding + sizeof_padding_class;
 }


        
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to