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
52 lines
792 B
C++
52 lines
792 B
C++
// RUN: %clang_cc1 -analyze -std=gnu++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
|
|
|
|
// expected-no-diagnostics
|
|
|
|
|
|
bool foo1(int x) {
|
|
start:
|
|
if (x != 3) {
|
|
++x;
|
|
void *ptr = &&start;
|
|
goto start;
|
|
}
|
|
end:
|
|
return false;
|
|
}
|
|
|
|
// Targeting a different label with the address-of-label operator.
|
|
bool foo2(int x) {
|
|
start:
|
|
if (x != 3) {
|
|
++x;
|
|
void *ptr = &&end;
|
|
goto start;
|
|
}
|
|
end:
|
|
return false;
|
|
}
|
|
|
|
// Different target label in goto
|
|
bool foo3(int x) {
|
|
start:
|
|
if (x != 3) {
|
|
++x;
|
|
void *ptr = &&start;
|
|
goto end;
|
|
}
|
|
end:
|
|
return false;
|
|
}
|
|
|
|
// FIXME: Can't detect same algorithm as in foo1 but with different label names.
|
|
bool foo4(int x) {
|
|
foo:
|
|
if (x != 3) {
|
|
++x;
|
|
void *ptr = &&foo;
|
|
goto foo;
|
|
}
|
|
end:
|
|
return false;
|
|
}
|