2017-09-04 13:56:36 +08:00
|
|
|
// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:MinimumCloneComplexity=10 -verify %s
|
2016-07-27 02:13:12 +08:00
|
|
|
|
|
|
|
// This tests if sub-sequences can match with normal sequences.
|
|
|
|
|
|
|
|
void log2(int a);
|
|
|
|
void log();
|
|
|
|
|
|
|
|
int max(int a, int b) {
|
|
|
|
log2(a);
|
2016-10-08 18:54:30 +08:00
|
|
|
log(); // expected-warning{{Duplicate code detected}}
|
2016-07-27 02:13:12 +08:00
|
|
|
if (a > b)
|
|
|
|
return a;
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
int maxClone(int a, int b) {
|
2016-10-08 18:54:30 +08:00
|
|
|
log(); // expected-note{{Similar code here}}
|
2016-07-27 02:13:12 +08:00
|
|
|
if (a > b)
|
|
|
|
return a;
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Functions below are not clones and should not be reported.
|
|
|
|
|
|
|
|
int foo(int a, int b) { // no-warning
|
|
|
|
return a + b;
|
|
|
|
}
|