aboutsummaryrefslogtreecommitdiff
path: root/clang/test/Analysis/PR57270.cpp
blob: 7d7a658ef441b4725dec0ad4a4e411d59beaebe2 (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 -analyzer-checker=debug.ExprInspection -verify %s

using size_t = __typeof(sizeof(int));

void clang_analyzer_explain(int);
void clang_analyzer_dump(int);
void *memset(void *, int, size_t);

struct S
{
    static int a;
    ~S(){};
};

int S::a = 0;

void foo()
{
    S::a = 0;

    int x = 3;
    memset(&x, 1, sizeof(x));

    S *arr = new S[x];
    delete[] arr;

    clang_analyzer_dump(S::a); // expected-warning-re{{{{derived_\$[0-9]+{conj_\$[0-9]+{int, LC[0-9]+, S[0-9]+, #[0-9]+},a}}}}}

    clang_analyzer_explain(S::a); // expected-warning-re{{{{value derived from \(symbol of type 'int' conjured at CFG element '->~S\(\) \(Implicit destructor\)'\) for global variable 'S::a'}}}}
}