llvm-project/clang/test/Analysis/traversal-path-unification.c
Aaron Ballman 1ea584377e A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the ninth batch of tests being updated (there are a
significant number of other tests left to be updated).
2022-02-13 08:03:40 -05:00

30 lines
701 B
C

// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.DumpTraversal %s | FileCheck %s
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.DumpTraversal -DUSE_EXPR %s | FileCheck %s
int a(void);
int b(void);
int c(void);
#ifdef USE_EXPR
#define CHECK(x) ((x) & 1)
#else
#define CHECK(x) (x)
#endif
// CHECK: --BEGIN FUNCTION--
void testRemoveDeadBindings(void) {
int i = a();
if (CHECK(i))
a();
else
b();
// At this point the symbol bound to 'i' is dead.
// The effects of a() and b() are identical (they both invalidate globals).
// We should unify the two paths here and only get one end-of-path node.
c();
}
// CHECK: --END FUNCTION--
// CHECK-NOT: --END FUNCTION--