Skip to content

Commit 0034ea6

Browse files
committed
Address feedback
1 parent ef0f044 commit 0034ea6

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

clang-tools-extra/test/clang-tidy/check_clang_tidy.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,9 @@ def parse_arguments() -> Tuple[argparse.Namespace, List[str]]:
385385
args, extra_args = parser.parse_known_args()
386386
if args.std is None:
387387
_, extension = os.path.splitext(args.assume_filename or args.input_file_name)
388-
args.std = (
389-
["c++11-or-later"]
390-
if extension in [".cpp", ".hpp", ".mm"]
391-
else ["c99-or-later"]
392-
)
388+
args.std = [
389+
"c++11-or-later" if extension in [".cpp", ".hpp", ".mm"] else "c99-or-later"
390+
]
393391

394392
return (args, extra_args)
395393

clang-tools-extra/test/clang-tidy/checkers/bugprone/easily-swappable-parameters-relatedness.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
// RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \
1+
// RUN: %check_clang_tidy -std=c99,c11,c17 -check-suffixes=,BEFORE-C23 %s bugprone-easily-swappable-parameters %t \
2+
// RUN: -config='{CheckOptions: { \
3+
// RUN: bugprone-easily-swappable-parameters.MinimumLength: 2, \
4+
// RUN: bugprone-easily-swappable-parameters.IgnoredParameterNames: "", \
5+
// RUN: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes: "", \
6+
// RUN: bugprone-easily-swappable-parameters.QualifiersMix: 0, \
7+
// RUN: bugprone-easily-swappable-parameters.ModelImplicitConversions: 0, \
8+
// RUN: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether: 1, \
9+
// RUN: bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold: 0 \
10+
// RUN: }}' -- -Wno-strict-prototypes -x c
11+
//
12+
// RUN: %check_clang_tidy -std=c23-or-later %s bugprone-easily-swappable-parameters %t \
213
// RUN: -config='{CheckOptions: { \
314
// RUN: bugprone-easily-swappable-parameters.MinimumLength: 2, \
415
// RUN: bugprone-easily-swappable-parameters.IgnoredParameterNames: "", \
@@ -18,16 +29,18 @@ void notRelated(int A, int B) {}
1829

1930
int addedTogether(int A, int B) { return add(A, B); } // NO-WARN: Passed to same function.
2031

21-
// FIXME: This triggers a false positive: the "passed to same function" heuristic
22-
// can't map the parameter index 1 to A and B because myprint() has no
23-
// parameters.
24-
// warning: 2 adjacent parameters of 'passedToSameKNRFunction' of similar type ('int')
25-
// note: the first parameter in the range is 'A'
26-
// note: the last parameter in the range is 'B'
27-
#if 0
32+
#if __STDC_VERSION__ < 202311L
2833
int myprint();
2934
void passedToSameKNRFunction(int A, int B) {
3035
myprint("foo", A);
3136
myprint("bar", B);
3237
}
38+
// CHECK-MESSAGES-BEFORE-C23: :[[@LINE-4]]:30: warning: 2 adjacent parameters of 'passedToSameKNRFunction' of similar type ('int')
39+
// CHECK-MESSAGES-BEFORE-C23: :[[@LINE-5]]:34: note: the first parameter in the range is 'A'
40+
// CHECK-MESSAGES-BEFORE-C23: :[[@LINE-6]]:41: note: the last parameter in the range is 'B'
41+
// FIXME: This is actually a false positive: the "passed to same function" heuristic
42+
// can't map the parameter index 1 to A and B because myprint() has no
43+
// parameters.
44+
// If you fix this, you should be able to combine the `%check_clang_tidy` invocations
45+
// in this file into one and remove the `-std` and `-check-suffixes` arguments.
3346
#endif

0 commit comments

Comments
 (0)