[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Analysis / new-ctor-inlined.cpp
blobca8c4da392d6df37f7ba9ffbb7b28bd19f6132c1
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config c++-allocator-inlining=true -std=c++11 -verify -analyzer-config eagerly-assume=false %s
3 void clang_analyzer_eval(bool);
5 typedef __typeof__(sizeof(int)) size_t;
7 void *conjure();
8 void exit(int);
10 void *operator new(size_t size) throw() {
11 void *x = conjure();
12 if (x == 0)
13 exit(1);
14 return x;
17 struct S {
18 int x;
19 S() : x(1) {}
20 ~S() {}
23 void checkNewAndConstructorInlining() {
24 S *s = new S;
25 // Check that the symbol for 's' is not dying.
26 clang_analyzer_eval(s != 0); // expected-warning{{TRUE}}
27 // Check that bindings are correct (and also not dying).
28 clang_analyzer_eval(s->x == 1); // expected-warning{{TRUE}}
31 struct Sp {
32 Sp *p;
33 Sp(Sp *p): p(p) {}
34 ~Sp() {}
37 void checkNestedNew() {
38 Sp *p = new Sp(new Sp(0));
39 clang_analyzer_eval(p->p->p == 0); // expected-warning{{TRUE}}
42 void checkNewPOD() {
43 int *i = new int;
44 clang_analyzer_eval(*i == 0); // expected-warning{{UNKNOWN}}
45 int *j = new int();
46 clang_analyzer_eval(*j == 0); // expected-warning{{TRUE}}
47 int *k = new int(5);
48 clang_analyzer_eval(*k == 5); // expected-warning{{TRUE}}
51 void checkTrivialCopy() {
52 S s;
53 S *t = new S(s); // no-crash
54 clang_analyzer_eval(t->x == 1); // expected-warning{{TRUE}}