CallExpr may have a null direct callee when the callee function is not known in compile-time. Do not try to take callee name in this case. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D23320 llvm-svn: 278238
37 lines
676 B
C++
37 lines
676 B
C++
// RUN: %clang_cc1 -analyze -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
|
|
|
|
// expected-no-diagnostics
|
|
|
|
bool a();
|
|
bool b();
|
|
|
|
// Calls method a with some extra code to pass the minimum complexity
|
|
bool foo1(int x) {
|
|
if (x > 0)
|
|
return false;
|
|
else if (x < 0)
|
|
return a();
|
|
return true;
|
|
}
|
|
|
|
// Calls method b with some extra code to pass the minimum complexity
|
|
bool foo2(int x) {
|
|
if (x > 0)
|
|
return false;
|
|
else if (x < 0)
|
|
return b();
|
|
return true;
|
|
}
|
|
|
|
// Test that we don't crash on function pointer calls
|
|
|
|
bool (*funcPtr)(int);
|
|
|
|
bool fooPtr1(int x) {
|
|
if (x > 0)
|
|
return false;
|
|
else if (x < 0)
|
|
return funcPtr(1);
|
|
return true;
|
|
}
|