aboutsummaryrefslogtreecommitdiff
path: root/clang/test/Analysis/padding_no_unique_address.cpp
blob: 4f26922c9450daaae572e0302726fa78ef0afc9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-linux-gnu -analyzer-checker=optin.performance -analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s

class Empty {}; // no-warning

// expected-warning@+1{{Excessive padding in 'struct NoUniqueAddressWarn1' (6 padding}}
struct NoUniqueAddressWarn1 {
  char c1;
  [[no_unique_address]] Empty empty;
  int i;
  char c2;
};

// expected-warning@+1{{Excessive padding in 'struct NoUniqueAddressWarn2' (6 padding}}
struct NoUniqueAddressWarn2 {
    char c1;
    [[no_unique_address]] Empty e1, e2;
    int i;
    char c2;
};

struct NoUniqueAddressNoWarn1 {
  char c1;
  [[no_unique_address]] Empty empty;
  char c2;
};

struct NoUniqueAddressNoWarn2 {
  char c1;
  [[no_unique_address]] Empty e1, e2;
};