xref: /aosp_15_r20/external/clang/test/Analysis/live-variables.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
2*67e74705SXin Li // expected-no-diagnostics
3*67e74705SXin Li class B {
4*67e74705SXin Li public:
5*67e74705SXin Li   bool m;
~B()6*67e74705SXin Li   ~B() {} // The destructor ensures that the binary logical operator below is wrapped in the ExprWithCleanups.
7*67e74705SXin Li };
8*67e74705SXin Li B foo();
9*67e74705SXin Li int getBool();
10*67e74705SXin Li int *getPtr();
test()11*67e74705SXin Li int test() {
12*67e74705SXin Li   int r = 0;
13*67e74705SXin Li   for (int x = 0; x< 10; x++) {
14*67e74705SXin Li     int *p = getPtr();
15*67e74705SXin Li     // Liveness info is not computed correctly due to the following expression.
16*67e74705SXin Li     // This happens due to CFG being special cased for short circuit operators.
17*67e74705SXin Li     // PR18159
18*67e74705SXin Li     if (p != 0 && getBool() && foo().m && getBool()) {
19*67e74705SXin Li       r = *p; // no warning
20*67e74705SXin Li     }
21*67e74705SXin Li   }
22*67e74705SXin Li   return r;
23*67e74705SXin Li }
24