1 // RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=optin.performance -analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s
3 // Make sure that the C cases still work fine, even when compiled as C++.
6 struct BigCharArray2
{ // no-warning
10 // xxxexpected-warning@+1{{Excessive padding in 'struct LowAlignmentBase'}}
11 struct LowAlignmentBase
: public BigCharArray2
{
16 struct CorrectLowAlignmentBase
: public BigCharArray2
{ // no-warning
21 // xxxexpected-warning@+1{{Excessive padding in 'struct LowAlignmentBase2'}}
22 struct LowAlignmentBase2
: public BigCharArray2
{
28 class PaddedA
{ // expected-warning{{Excessive padding in 'class PaddedA'}}
34 class VirtualPaddedA
: public PaddedA
{ // no-warning
38 class VirtualIntSandwich
{ // expected-warning{{Excessive padding in 'class VirtualIntSandwich'}}
45 // constructed so as not to have tail padding
46 class InnerPaddedB
{ // expected-warning{{Excessive padding in 'class InnerPaddedB'}}
53 class TailPaddedB
{ // expected-warning{{Excessive padding in 'class TailPaddedB'}}
59 class SI
: public PaddedA
{ // no-warning
63 class SI2
: public PaddedA
{ // xxxexpected-warning{{Excessive padding in 'class SI2'}}
69 class VirtualSI
: virtual public PaddedA
{ // no-warning
73 // currently not checked for
74 class VirtualSI2
: virtual public PaddedA
{ // no-warning
80 class VtblSI
: public PaddedA
{ // no-warning
85 class VtblSI2
: public PaddedA
{ // xxxexpected-warning{{Excessive padding in 'class VtblSI2'}}
92 class VtblSI3
: public VirtualPaddedA
{ // xxxexpected-warning{{Excessive padding in 'class VtblSI3'}}
98 class MI
: public PaddedA
, public InnerPaddedB
{ // no-warning
102 class MI2
: public PaddedA
, public InnerPaddedB
{ // xxxexpected-warning{{Excessive padding in 'class MI2'}}
108 class VtblMI
: public PaddedA
, public InnerPaddedB
{ // xxxexpected-warning{{Excessive padding in 'class VtblMI'}}
109 virtual void foo() {}
115 class VtblMI2
: public VirtualPaddedA
, public InnerPaddedB
{ // xxxexpected-warning{{Excessive padding in 'class VtblMI2'}}
121 class Empty
{}; // no-warning
123 class LotsOfSpace
{ // expected-warning{{Excessive padding in 'class LotsOfSpace'}}
129 class EBO1
: public Empty
{ // xxxexpected-warning{{Excessive padding in 'class EBO1'}}
135 class EBO2
: public Empty
{ // xxxexpected-warning{{Excessive padding in 'class EBO2'}}
141 template <typename T
>
142 class TemplateSandwich
{ // expected-warning{{Excessive padding in 'class TemplateSandwich<int>' instantiated here}}
148 template <typename T
>
149 class TemplateSandwich
<T
*> { // expected-warning{{Excessive padding in 'class TemplateSandwich<void *>' instantiated here}}
156 class TemplateSandwich
<long long> { // expected-warning{{Excessive padding in 'class TemplateSandwich<long long>' (}}
162 class Holder1
{ // no-warning
163 TemplateSandwich
<int> t1
;
164 TemplateSandwich
<char> t2
;
165 TemplateSandwich
<void *> t3
;
168 typedef struct TypedefSandwich2
{ // expected-warning{{Excessive padding in 'struct TypedefSandwich2'}}
170 typedef struct { // expected-warning{{Excessive padding in 'TypedefSandwich2::NestedTypedef'}}
179 template <typename T
>
181 // expected-warning@+1{{Excessive padding in 'struct Foo<int>::Nested'}}
189 struct Holder
{ // no-warning
191 Foo
<char>::Nested t2
;
194 struct GlobalsForLambda
{ // no-warning
200 // expected-warning@+1{{Excessive padding in 'class (lambda}}
201 auto lambda1
= [ c1
= G
.c1
, i
= G
.i
, c2
= G
.c2
]{};
202 auto lambda2
= [ i
= G
.i
, c1
= G
.c1
, c2
= G
.c2
]{}; // no-warning