diff options
Diffstat (limited to 'clang/test/Analysis/padding_message.cpp')
| -rw-r--r-- | clang/test/Analysis/padding_message.cpp | 166 |
1 files changed, 146 insertions, 20 deletions
diff --git a/clang/test/Analysis/padding_message.cpp b/clang/test/Analysis/padding_message.cpp index f73a11af4e7..bbfa45394d8 100644 --- a/clang/test/Analysis/padding_message.cpp +++ b/clang/test/Analysis/padding_message.cpp @@ -1,13 +1,25 @@ // RUN: %clang_cc1 -triple x86_64-unknown-linux -std=c++14 -analyze -analyzer-checker=optin.performance -analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s -// expected-warning@+1{{Excessive padding in 'struct IntSandwich' (6 padding bytes, where 2 is optimal)}} +// expected-warning@+7{{\ +Excessive padding in 'struct IntSandwich' (6 padding bytes, where 2 is optimal). \ +Optimal fields order: \ +i, \ +c1, \ +c2, \ +}} struct IntSandwich { char c1; int i; char c2; }; -// expected-warning@+1{{Excessive padding in 'struct TurDuckHen' (6 padding bytes, where 2 is optimal)}} +// expected-warning@+7{{\ +Excessive padding in 'struct TurDuckHen' (6 padding bytes, where 2 is optimal). \ +Optimal fields order: \ +i, \ +c1, \ +c2, \ +}} struct TurDuckHen { char c1; struct IntSandwich i; @@ -16,7 +28,17 @@ struct TurDuckHen { #pragma pack(push) #pragma pack(2) -// expected-warning@+1{{Excessive padding in 'struct SmallIntSandwich' (4 padding bytes, where 0 is optimal)}} +// expected-warning@+11{{\ +Excessive padding in 'struct SmallIntSandwich' (4 padding bytes, where 0 is optimal). \ +Optimal fields order: \ +i1, \ +i2, \ +i3, \ +c1, \ +c2, \ +c3, \ +c4, \ +}} struct SmallIntSandwich { char c1; int i1; @@ -34,7 +56,13 @@ union SomeUnion { // no-warning int i; }; -// expected-warning@+1{{Excessive padding in 'struct HoldsAUnion' (6 padding bytes, where 2 is optimal)}} +// expected-warning@+7{{\ +Excessive padding in 'struct HoldsAUnion' (6 padding bytes, where 2 is optimal). \ +Optimal fields order: \ +u, \ +c1, \ +c2, \ +}} struct HoldsAUnion { char c1; union SomeUnion u; @@ -49,28 +77,53 @@ struct MediumIntArray { // no-warning int i[5]; }; -// expected-warning@+1{{Excessive padding in 'struct StructSandwich' (6 padding bytes, where 2 is optimal)}} +// expected-warning@+7{{\ +Excessive padding in 'struct StructSandwich' (6 padding bytes, where 2 is optimal). \ +Optimal fields order: \ +m, \ +s, \ +s2, \ +}} struct StructSandwich { struct SmallCharArray s; struct MediumIntArray m; struct SmallCharArray s2; }; -// expected-warning@+1{{Excessive padding in 'TypedefSandwich' (6 padding bytes, where 2 is optimal)}} +// expected-warning@+7{{\ +Excessive padding in 'TypedefSandwich' (6 padding bytes, where 2 is optimal). \ +Optimal fields order: \ +i, \ +c1, \ +c2, \ +}} typedef struct { char c1; int i; char c2; } TypedefSandwich; -// expected-warning@+1{{Excessive padding in 'struct StructAttrAlign' (10 padding bytes, where 2 is optimal)}} +// expected-warning@+7{{\ +Excessive padding in 'struct StructAttrAlign' (10 padding bytes, where 2 is optimal). \ +Optimal fields order: \ +i, \ +c1, \ +c2, \ +}} struct StructAttrAlign { char c1; int i; char c2; } __attribute__((aligned(8))); -// expected-warning@+1{{Excessive padding in 'struct OverlyAlignedChar' (8185 padding bytes, where 4089 is optimal)}} +// expected-warning@+8{{\ +Excessive padding in 'struct OverlyAlignedChar' (8185 padding bytes, where 4089 is optimal). \ +Optimal fields order: \ +c, \ +c1, \ +c2, \ +x, \ +}} struct OverlyAlignedChar { char c1; int x; @@ -78,7 +131,13 @@ struct OverlyAlignedChar { char c __attribute__((aligned(4096))); }; -// expected-warning@+1{{Excessive padding in 'struct HoldsOverlyAlignedChar' (8190 padding bytes, where 4094 is optimal)}} +// expected-warning@+7{{\ +Excessive padding in 'struct HoldsOverlyAlignedChar' (8190 padding bytes, where 4094 is optimal). \ +Optimal fields order: \ +o, \ +c1, \ +c2, \ +}} struct HoldsOverlyAlignedChar { char c1; struct OverlyAlignedChar o; @@ -86,7 +145,13 @@ struct HoldsOverlyAlignedChar { }; void internalStructFunc() { - // expected-warning@+1{{Excessive padding in 'struct X' (6 padding bytes, where 2 is optimal)}} + // expected-warning@+7{{\ +Excessive padding in 'struct X' (6 padding bytes, where 2 is optimal). \ +Optimal fields order: \ +t, \ +c1, \ +c2, \ +}} struct X { char c1; int t; @@ -96,7 +161,13 @@ void internalStructFunc() { } void typedefStructFunc() { - // expected-warning@+1{{Excessive padding in 'S' (6 padding bytes, where 2 is optimal)}} + // expected-warning@+7{{\ +Excessive padding in 'S' (6 padding bytes, where 2 is optimal). \ +Optimal fields order: \ +t, \ +c1, \ +c2, \ +}} typedef struct { char c1; int t; @@ -105,21 +176,39 @@ void typedefStructFunc() { S obj; } -// expected-warning@+1{{Excessive padding in 'struct DefaultAttrAlign' (22 padding bytes, where 6 is optimal)}} +// expected-warning@+7{{\ +Excessive padding in 'struct DefaultAttrAlign' (22 padding bytes, where 6 is optimal). \ +Optimal fields order: \ +i, \ +c1, \ +c2, \ +}} struct DefaultAttrAlign { char c1; long long i; char c2; } __attribute__((aligned)); -// expected-warning@+1{{Excessive padding in 'struct SmallArrayShortSandwich' (2 padding bytes, where 0 is optimal)}} +// expected-warning@+7{{\ +Excessive padding in 'struct SmallArrayShortSandwich' (2 padding bytes, where 0 is optimal). \ +Optimal fields order: \ +s, \ +c1, \ +c2, \ +}} struct SmallArrayShortSandwich { char c1; short s; char c2; } ShortArray[20]; -// expected-warning@+1{{Excessive padding in 'struct SmallArrayInFunc' (2 padding bytes, where 0 is optimal)}} +// expected-warning@+7{{\ +Excessive padding in 'struct SmallArrayInFunc' (2 padding bytes, where 0 is optimal). \ +Optimal fields order: \ +s, \ +c1, \ +c2, \ +}} struct SmallArrayInFunc { char c1; short s; @@ -130,7 +219,13 @@ void arrayHolder() { struct SmallArrayInFunc Arr[15]; } -// expected-warning@+1{{Excessive padding in 'class VirtualIntSandwich' (10 padding bytes, where 2 is optimal)}} +// expected-warning@+7{{\ +Excessive padding in 'class VirtualIntSandwich' (10 padding bytes, where 2 is optimal). \ +Optimal fields order: \ +i, \ +c1, \ +c2, \ +}} class VirtualIntSandwich { virtual void foo() {} char c1; @@ -139,7 +234,14 @@ class VirtualIntSandwich { }; // constructed so as not to have tail padding -// expected-warning@+1{{Excessive padding in 'class InnerPaddedB' (6 padding bytes, where 2 is optimal)}} +// expected-warning@+8{{\ +Excessive padding in 'class InnerPaddedB' (6 padding bytes, where 2 is optimal). \ +Optimal fields order: \ +i1, \ +i2, \ +c1, \ +c2, \ +}} class InnerPaddedB { char c1; int i1; @@ -149,17 +251,35 @@ class InnerPaddedB { class Empty {}; // no-warning -// expected-warning@+1{{Excessive padding in 'class LotsOfSpace' (6 padding bytes, where 2 is optimal)}} +// expected-warning@+7{{\ +Excessive padding in 'class LotsOfSpace' (6 padding bytes, where 2 is optimal). \ +Optimal fields order: \ +i, \ +e1, \ +e2, \ +}} class LotsOfSpace { Empty e1; int i; Empty e2; }; -// expected-warning@+1{{Excessive padding in 'TypedefSandwich2' (6 padding bytes, where 2 is optimal)}} +// expected-warning@+7{{\ +Excessive padding in 'TypedefSandwich2' (6 padding bytes, where 2 is optimal). \ +Optimal fields order: \ +t, \ +c1, \ +c2, \ +}} typedef struct { char c1; - // expected-warning@+1{{Excessive padding in 'TypedefSandwich2::NestedTypedef' (6 padding bytes, where 2 is optimal)}} + // expected-warning@+7{{\ +Excessive padding in 'TypedefSandwich2::NestedTypedef' (6 padding bytes, where 2 is optimal). \ +Optimal fields order: \ +i, \ +c1, \ +c2, \ +}} typedef struct { char c1; int i; @@ -171,7 +291,13 @@ typedef struct { template <typename T> struct Foo { - // expected-warning@+1{{Excessive padding in 'struct Foo<int>::Nested' (6 padding bytes, where 2 is optimal)}} + // expected-warning@+7{{\ +Excessive padding in 'struct Foo<int>::Nested' (6 padding bytes, where 2 is optimal). \ +Optimal fields order: \ +t, \ +c1, \ +c2, \ +}} struct Nested { char c1; T t; |

