aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/test/clang-tidy/checkers/readability
diff options
context:
space:
mode:
authorFelix <felix-antoine.constantin@polymtl.ca>2023-10-09 17:55:39 +0000
committerPiotr Zegar <me@piotrzegar.pl>2023-10-09 19:58:44 +0000
commit7a73da4c85a12341752a4573c55ebff46ba20db0 (patch)
treeb53c7902604fe327d6a29f643b71e08ee7cffaa8 /clang-tools-extra/test/clang-tidy/checkers/readability
parent1684c65bc997a8ce0ecf96a493784fe39def75de (diff)
downloadllvm-7a73da4c85a12341752a4573c55ebff46ba20db0.zip
llvm-7a73da4c85a12341752a4573c55ebff46ba20db0.tar.gz
llvm-7a73da4c85a12341752a4573c55ebff46ba20db0.tar.bz2
[clang-tidy] Add support for optional parameters in config.
If a parameter value is either 'none', 'null', 'false', '-1' or '', we will in that case use the default value. Reviewed By: PiotrZSL Differential Revision: https://reviews.llvm.org/D159436
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/checkers/readability')
-rw-r--r--clang-tools-extra/test/clang-tidy/checkers/readability/function-size.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/function-size.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/function-size.cpp
index b6a7946..45b2604 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/readability/function-size.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/readability/function-size.cpp
@@ -8,6 +8,16 @@
// RUN: readability-function-size.VariableThreshold: 1 \
// RUN: }}'
+
+// RUN: %check_clang_tidy -check-suffixes=OPTIONAL %s readability-function-size %t -- \
+// RUN: -config='{CheckOptions: { \
+// RUN: readability-function-size.StatementThreshold: "-1", \
+// RUN: readability-function-size.BranchThreshold: "5", \
+// RUN: readability-function-size.ParameterThreshold: "none", \
+// RUN: readability-function-size.NestingThreshold: "", \
+// RUN: readability-function-size.VariableThreshold: "" \
+// RUN: }}'
+
// Bad formatting is intentional, don't run clang-format over the whole file!
void foo1() {
@@ -103,9 +113,11 @@ void baz0() { // 1
// check that nested if's are not reported. this was broken initially
void nesting_if() { // 1
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'nesting_if' exceeds recommended size/complexity
- // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 23 lines including whitespace and comments (threshold 0)
+ // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 25 lines including whitespace and comments (threshold 0)
// CHECK-MESSAGES: :[[@LINE-3]]:6: note: 18 statements (threshold 0)
// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 6 branches (threshold 0)
+ // CHECK-MESSAGES-OPTIONAL: :[[@LINE-5]]:6: warning: function 'nesting_if' exceeds recommended size/complexity
+ // CHECK-MESSAGES-OPTIONAL: :[[@LINE-6]]:6: note: 6 branches (threshold 5)
if (true) { // 2
int j;
} else if (true) { // 2
@@ -123,7 +135,7 @@ void nesting_if() { // 1
} else if (true) { // 2
int j;
}
- // CHECK-MESSAGES: :[[@LINE-22]]:6: note: 6 variables (threshold 1)
+ // CHECK-MESSAGES: :[[@LINE-24]]:6: note: 6 variables (threshold 1)
}
// however this should warn