Files
clang-p2996/clang/test/Analysis/copypaste/fold.cpp
Artem Dergachev 78692ea590 [analyzer] Respect statement-specific data in CloneDetection.
So far the CloneDetector only respected the kind of each statement when
searching for clones. This patch refines the way the CloneDetector collects data
from each statement by providing methods for each statement kind,
that will read the kind-specific attributes.

For example, statements 'a < b' and 'a > b' are no longer considered to be
clones, because they are different in operation code, which is an attribute
specific to the BinaryOperator statement kind.

Patch by Raphael Isemann!

Differential Revision: https://reviews.llvm.org/D22514

llvm-svn: 277449
2016-08-02 12:21:09 +00:00

36 lines
675 B
C++

// RUN: %clang_cc1 -analyze -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -verify %s
// expected-no-diagnostics
int global = 0;
template<typename ...Args>
int foo1(Args&&... args) {
if (global > 0)
return 0;
else if (global < 0)
return (args + ...);
return 1;
}
// Different opeator in fold expression.
template<typename ...Args>
int foo2(Args&&... args) {
if (global > 0)
return 0;
else if (global < 0)
return (args - ...);
return 1;
}
// Parameter pack on a different side
template<typename ...Args>
int foo3(Args&&... args) {
if (global > 0)
return 0;
else if (global < 0)
return -1;
return (... + args);
return 1;
}