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