xref: /minix3/external/bsd/llvm/dist/clang/test/Analysis/traversal-path-unification.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.DumpTraversal %s | FileCheck %s
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.DumpTraversal -DUSE_EXPR %s | FileCheck %s
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc int a();
5*f4a2713aSLionel Sambuc int b();
6*f4a2713aSLionel Sambuc int c();
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc #ifdef USE_EXPR
9*f4a2713aSLionel Sambuc #define CHECK(x) ((x) & 1)
10*f4a2713aSLionel Sambuc #else
11*f4a2713aSLionel Sambuc #define CHECK(x) (x)
12*f4a2713aSLionel Sambuc #endif
13*f4a2713aSLionel Sambuc 
testRemoveDeadBindings()14*f4a2713aSLionel Sambuc void testRemoveDeadBindings() {
15*f4a2713aSLionel Sambuc   int i = a();
16*f4a2713aSLionel Sambuc   if (CHECK(i))
17*f4a2713aSLionel Sambuc     a();
18*f4a2713aSLionel Sambuc   else
19*f4a2713aSLionel Sambuc     b();
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc   // At this point the symbol bound to 'i' is dead.
22*f4a2713aSLionel Sambuc   // The effects of a() and b() are identical (they both invalidate globals).
23*f4a2713aSLionel Sambuc   // We should unify the two paths here and only get one end-of-path node.
24*f4a2713aSLionel Sambuc   c();
25*f4a2713aSLionel Sambuc }
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc // CHECK: --END FUNCTION--
28*f4a2713aSLionel Sambuc // CHECK-NOT: --END FUNCTION--
29