
Summary: So far we used a value of 10 which was useful for testing but produces many false-positives in real programs. The usual suspicious clones we find seem to be at around a complexity value of 70 and for normal clone-reporting everything above 50 seems to be a valid normal clone for users, so let's just go with 50 for now and set this as the new default value. This patch also explicitly sets the complexity value for the regression tests as they serve more of a regression testing/debugging purpose and shouldn't really be reported by default in real programs. I'll add more tests that reflect actual found bugs that then need to pass with the default setting in the future. Reviewers: NoQ Subscribers: cfe-commits, javed.absar, xazax.hun, v.g.vassilev Differential Revision: https://reviews.llvm.org/D34178 llvm-svn: 312468
29 lines
539 B
C++
29 lines
539 B
C++
// RUN: %clang_analyze_cc1 -std=c++1z -analyzer-checker=alpha.clone.CloneChecker -analyzer-config alpha.clone.CloneChecker:MinimumCloneComplexity=10 -verify %s
|
|
|
|
// expected-no-diagnostics
|
|
|
|
int foo1(int n) {
|
|
int result = 0;
|
|
switch (n) {
|
|
case 33:
|
|
result += 33;
|
|
[[clang::fallthrough]];
|
|
case 44:
|
|
result += 44;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
// Identical to foo1 except the missing attribute.
|
|
int foo2(int n) {
|
|
int result = 0;
|
|
switch (n) {
|
|
case 33:
|
|
result += 33;
|
|
;
|
|
case 44:
|
|
result += 44;
|
|
}
|
|
return result;
|
|
}
|