blob: 8bef2ed2402c7c9c071b1ef9bf72ff25643b223f [file] [log] [blame]
Artem Dergachev55796302018-01-17 22:34:23 +00001// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config c++-allocator-inlining=true -std=c++11 -verify %s
2
3void clang_analyzer_eval(bool);
4void clang_analyzer_warnOnDeadSymbol(int);
5
6typedef __typeof__(sizeof(int)) size_t;
7
8int conjure();
9void exit(int);
10
11struct S {
12 S() {}
13 ~S() {}
14
15 static S buffer[1000];
16
17 // This operator allocates stuff within the buffer. Additionally, it never
18 // places anything at the beginning of the buffer.
19 void *operator new(size_t size) {
20 int i = conjure();
21 if (i == 0)
22 exit(1);
23 // Let's see if the symbol dies before new-expression is evaluated.
24 // It shouldn't.
25 clang_analyzer_warnOnDeadSymbol(i);
26 return buffer + i;
27 }
28};
29
30void testIndexLiveness() {
31 S *s = new S();
32 clang_analyzer_eval(s == S::buffer); // expected-warning{{FALSE}}
33} // expected-warning{{SYMBOL DEAD}}