| 1 |
// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:MinimumCloneComplexity=10 -verify %s |
| 2 |
|
| 3 |
// This tests if sub-sequences can match with normal sequences. |
| 4 |
|
| 5 |
void log2(int a); |
| 6 |
void log(); |
| 7 |
|
| 8 |
int max(int a, int b) { |
| 9 |
log2(a); |
| 10 |
log(); // expected-warning{{Duplicate code detected}} |
| 11 |
if (a > b) |
| 12 |
return a; |
| 13 |
return b; |
| 14 |
} |
| 15 |
|
| 16 |
int maxClone(int a, int b) { |
| 17 |
log(); // expected-note{{Similar code here}} |
| 18 |
if (a > b) |
| 19 |
return a; |
| 20 |
return b; |
| 21 |
} |
| 22 |
|
| 23 |
// Functions below are not clones and should not be reported. |
| 24 |
|
| 25 |
int foo(int a, int b) { // no-warning |
| 26 |
return a + b; |
| 27 |
} |