brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · bf9ceb1 Raw
29 lines · cpp
1// RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \2// RUN:   -config='{CheckOptions: { \3// RUN:     bugprone-easily-swappable-parameters.MinimumLength: 3, \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: 0, \9// RUN:     bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityThreshold: 0 \10// RUN:  }}' --11 12int add(int Left, int Right) { return Left + Right; } // NO-WARN: Only 2 parameters.13 14int magic(int Left, int Right, int X, int Y) { return 0; }15// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: 4 adjacent parameters of 'magic' of similar type ('int') are easily swapped by mistake [bugprone-easily-swappable-parameters]16// CHECK-MESSAGES: :[[@LINE-2]]:15: note: the first parameter in the range is 'Left'17// CHECK-MESSAGES: :[[@LINE-3]]:43: note: the last parameter in the range is 'Y'18 19void multipleDistinctTypes(int I, int J, int K,20                           long L, long M,21                           double D, double E, double F) {}22// CHECK-MESSAGES: :[[@LINE-3]]:28: warning: 3 adjacent parameters of 'multipleDistinctTypes' of similar type ('int')23// CHECK-MESSAGES: :[[@LINE-4]]:32: note: the first parameter in the range is 'I'24// CHECK-MESSAGES: :[[@LINE-5]]:46: note: the last parameter in the range is 'K'25// NO-WARN: The [long, long] range is length of 2.26// CHECK-MESSAGES: :[[@LINE-5]]:28: warning: 3 adjacent parameters of 'multipleDistinctTypes' of similar type ('double')27// CHECK-MESSAGES: :[[@LINE-6]]:35: note: the first parameter in the range is 'D'28// CHECK-MESSAGES: :[[@LINE-7]]:55: note: the last parameter in the range is 'F'29