diff options
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/checkers/bugprone')
11 files changed, 158 insertions, 109 deletions
diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/incorrect-enable-shared-from-this.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/incorrect-enable-shared-from-this.cpp index 82b6ea8..81d5cc5 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/incorrect-enable-shared-from-this.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/incorrect-enable-shared-from-this.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes -std=c++11-or-later %s bugprone-incorrect-enable-shared-from-this %t +// RUN: %check_clang_tidy -std=c++11-or-later %s bugprone-incorrect-enable-shared-from-this %t // NOLINTBEGIN namespace std { @@ -8,15 +8,15 @@ namespace std { class BadClassExample : std::enable_shared_from_this<BadClassExample> {}; // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'BadClassExample' is not publicly inheriting from 'std::enable_shared_from_this', which will cause unintended behaviour when using 'shared_from_this'; make the inheritance public [bugprone-incorrect-enable-shared-from-this] -// CHECK-FIXES: public std::enable_shared_from_this<BadClassExample> +// CHECK-FIXES: class BadClassExample : public std::enable_shared_from_this<BadClassExample> {}; class BadClass2Example : private std::enable_shared_from_this<BadClass2Example> {}; // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'BadClass2Example' is not publicly inheriting from 'std::enable_shared_from_this', which will cause unintended behaviour when using 'shared_from_this'; make the inheritance public [bugprone-incorrect-enable-shared-from-this] -// CHECK-FIXES: public std::enable_shared_from_this<BadClass2Example> +// CHECK-FIXES: class BadClass2Example : public std::enable_shared_from_this<BadClass2Example> {}; struct BadStructExample : private std::enable_shared_from_this<BadStructExample> {}; // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: 'BadStructExample' is not publicly inheriting from 'std::enable_shared_from_this', which will cause unintended behaviour when using 'shared_from_this'; make the inheritance public [bugprone-incorrect-enable-shared-from-this] -// CHECK-FIXES: public std::enable_shared_from_this<BadStructExample> +// CHECK-FIXES: struct BadStructExample : public std::enable_shared_from_this<BadStructExample> {}; class GoodClassExample : public std::enable_shared_from_this<GoodClassExample> {}; @@ -29,15 +29,15 @@ class dummy_class2 {}; class BadMultiClassExample : std::enable_shared_from_this<BadMultiClassExample>, dummy_class1 {}; // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'BadMultiClassExample' is not publicly inheriting from 'std::enable_shared_from_this', which will cause unintended behaviour when using 'shared_from_this'; make the inheritance public [bugprone-incorrect-enable-shared-from-this] -// CHECK-FIXES: public std::enable_shared_from_this<BadMultiClassExample>, dummy_class1 +// CHECK-FIXES: class BadMultiClassExample : public std::enable_shared_from_this<BadMultiClassExample>, dummy_class1 {}; class BadMultiClass2Example : dummy_class1, std::enable_shared_from_this<BadMultiClass2Example>, dummy_class2 {}; // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'BadMultiClass2Example' is not publicly inheriting from 'std::enable_shared_from_this', which will cause unintended behaviour when using 'shared_from_this'; make the inheritance public [bugprone-incorrect-enable-shared-from-this] -// CHECK-FIXES: dummy_class1, public std::enable_shared_from_this<BadMultiClass2Example>, dummy_class2 +// CHECK-FIXES: class BadMultiClass2Example : dummy_class1, public std::enable_shared_from_this<BadMultiClass2Example>, dummy_class2 {}; class BadMultiClass3Example : dummy_class1, dummy_class2, std::enable_shared_from_this<BadMultiClass3Example> {}; // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'BadMultiClass3Example' is not publicly inheriting from 'std::enable_shared_from_this', which will cause unintended behaviour when using 'shared_from_this'; make the inheritance public [bugprone-incorrect-enable-shared-from-this] -// CHECK-FIXES: dummy_class1, dummy_class2, public std::enable_shared_from_this<BadMultiClass3Example> +// CHECK-FIXES: class BadMultiClass3Example : dummy_class1, dummy_class2, public std::enable_shared_from_this<BadMultiClass3Example> {}; class ClassBase : public std::enable_shared_from_this<ClassBase> {}; class PrivateInheritClassBase : private ClassBase {}; diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/move-forwarding-reference.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/move-forwarding-reference.cpp index 66cd6ba..9f45367 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/move-forwarding-reference.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/move-forwarding-reference.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes -std=c++14-or-later %s bugprone-move-forwarding-reference %t -- -- -fno-delayed-template-parsing +// RUN: %check_clang_tidy -std=c++14-or-later %s bugprone-move-forwarding-reference %t -- -- -fno-delayed-template-parsing namespace std { template <typename> struct remove_reference; @@ -121,5 +121,5 @@ template <typename T, typename U> void f11(U &&SomeU) { template <typename T> void f12() { [] (auto&& x) { T SomeT(std::move(x)); }; // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: forwarding reference passed to - // CHECK-FIXES: [] (auto&& x) { T SomeT(std::forward<decltype(x)>(x)); } + // CHECK-FIXES: [] (auto&& x) { T SomeT(std::forward<decltype(x)>(x)); }; } diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-in-initialization-strlen.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-in-initialization-strlen.c index b241d68..99d19ec 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-in-initialization-strlen.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-in-initialization-strlen.c @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes %s bugprone-not-null-terminated-result %t -- \ +// RUN: %check_clang_tidy %s bugprone-not-null-terminated-result %t -- \ // RUN: -- -I %S/Inputs/not-null-terminated-result #include "not-null-terminated-result-c.h" @@ -40,7 +40,7 @@ int bad_strncmp_1(char *str1, const char *str2) { int length = strlen(str1) + 1; return strncmp(str1, str2, length); // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: comparison length is too long and might lead to a buffer overflow [bugprone-not-null-terminated-result] - // CHECK-FIXES: strncmp(str1, str2, length - 1); + // CHECK-FIXES: return strncmp(str1, str2, length - 1); } int good_strncmp_1(char *str1, const char *str2) { @@ -51,13 +51,13 @@ int good_strncmp_1(char *str1, const char *str2) { int bad_strncmp_2(char *str2) { return strncmp(str2, "foobar", (strlen("foobar") + 1)); // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: comparison length is too long and might lead to a buffer overflow [bugprone-not-null-terminated-result] - // CHECK-FIXES: strncmp(str2, "foobar", (strlen("foobar"))); + // CHECK-FIXES: return strncmp(str2, "foobar", (strlen("foobar"))); } int bad_strncmp_3(char *str3) { return strncmp(str3, "foobar", 1 + strlen("foobar")); // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: comparison length is too long and might lead to a buffer overflow [bugprone-not-null-terminated-result] - // CHECK-FIXES: strncmp(str3, "foobar", strlen("foobar")); + // CHECK-FIXES: return strncmp(str3, "foobar", strlen("foobar")); } int good_strncmp_2_3(char *str) { diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-memcpy-safe-cxx.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-memcpy-safe-cxx.cpp index 8124b3b..8465b2b 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-memcpy-safe-cxx.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-memcpy-safe-cxx.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes %s bugprone-not-null-terminated-result %t -- \ +// RUN: %check_clang_tidy %s bugprone-not-null-terminated-result %t -- \ // RUN: -- -std=c++11 -I %S/Inputs/not-null-terminated-result #include "not-null-terminated-result-cxx.h" @@ -27,7 +27,7 @@ void bad_memcpy_known_dest(const char *src) { char dest01[13]; memcpy(dest01, src, strlen(src)); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'memcpy' is not null-terminated [bugprone-not-null-terminated-result] - // CHECK-FIXES: dest01[14]; + // CHECK-FIXES: char dest01[14]; // CHECK-FIXES-NEXT: strcpy_s(dest01, src); } @@ -44,7 +44,7 @@ void bad_memcpy_full_source_length(std::string src) { char *dest20 = reinterpret_cast<char *>(malloc(src.size())); memcpy(dest20, src.data(), src.size()); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'memcpy' is not null-terminated [bugprone-not-null-terminated-result] - // CHECK-FIXES: dest20 = reinterpret_cast<char *>(malloc(src.size() + 1)); + // CHECK-FIXES: char *dest20 = reinterpret_cast<char *>(malloc(src.size() + 1)); // CHECK-FIXES-NEXT: strcpy(dest20, src.data()); } diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-strlen.c b/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-strlen.c index 366c169..dccf4ed 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-strlen.c +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-strlen.c @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes %s bugprone-not-null-terminated-result %t -- \ +// RUN: %check_clang_tidy %s bugprone-not-null-terminated-result %t -- \ // RUN: -- -I %S/Inputs/not-null-terminated-result // FIXME: Something wrong with the APInt un/signed conversion on Windows: @@ -70,13 +70,13 @@ void good_strerror_s(int errno) { int bad_strncmp_1(char *str0, const char *str1) { return strncmp(str0, str1, (strlen(str0) + 1)); // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: comparison length is too long and might lead to a buffer overflow [bugprone-not-null-terminated-result] - // CHECK-FIXES: strncmp(str0, str1, (strlen(str0))); + // CHECK-FIXES: return strncmp(str0, str1, (strlen(str0))); } int bad_strncmp_2(char *str2, const char *str3) { return strncmp(str2, str3, 1 + strlen(str2)); // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: comparison length is too long and might lead to a buffer overflow [bugprone-not-null-terminated-result] - // CHECK-FIXES: strncmp(str2, str3, strlen(str2)); + // CHECK-FIXES: return strncmp(str2, str3, strlen(str2)); } int good_strncmp_1_2(char *str4, const char *str5) { @@ -86,7 +86,7 @@ int good_strncmp_1_2(char *str4, const char *str5) { int bad_strncmp_3(char *str6) { return strncmp(str6, "string", 7); // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: comparison length is too long and might lead to a buffer overflow [bugprone-not-null-terminated-result] - // CHECK-FIXES: strncmp(str6, "string", 6); + // CHECK-FIXES: return strncmp(str6, "string", 6); } int good_strncmp_3(char *str7) { diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-value-dependent-crash.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-value-dependent-crash.cpp new file mode 100644 index 0000000..5f361c3 --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-value-dependent-crash.cpp @@ -0,0 +1,23 @@ +// RUN: %check_clang_tidy %s bugprone-not-null-terminated-result %t -- \ +// RUN: -- -std=c++17 -I %S/Inputs/not-null-terminated-result + +// This test case reproduces the crash when the check tries to evaluate +// a value-dependent expression using EvaluateAsInt() in +// bugprone-not-null-terminated-result, where the src parameter of memcpy is +// value-dependent, but the length is not. + +// expected-no-diagnostics + +#include "not-null-terminated-result-cxx.h" + +template<size_t N> +class ValueDependentClass { +public: + void copyData(char* Dst) { + const char* Src = reinterpret_cast<const char*>(this); + // The length parameter is arbitrary, but the crash is not reproduced if it is N. + memcpy(Dst, Src, 32); + } +}; + +template class ValueDependentClass<42>; // The template parameter value is arbitrary. diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-wcslen.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-wcslen.cpp index 06e2db9..8047db3 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-wcslen.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-wcslen.cpp @@ -1,5 +1,5 @@ -// RUN: %check_clang_tidy --match-partial-fixes %s bugprone-not-null-terminated-result %t -- \ -// RUN: -- -std=c++11 -I %S/Inputs/not-null-terminated-result +// RUN: %check_clang_tidy -std=c++11-or-later %s bugprone-not-null-terminated-result %t -- \ +// RUN: -- -I %S/Inputs/not-null-terminated-result // FIXME: Something wrong with the APInt un/signed conversion on Windows: // in 'wcsncmp(wcs6, L"string", 7);' it tries to inject '4294967302' as length. @@ -58,13 +58,13 @@ void good_wmemmove_s_1(wchar_t *dest, const wchar_t *src) { int bad_wcsncmp_1(wchar_t *wcs0, const wchar_t *wcs1) { return wcsncmp(wcs0, wcs1, (wcslen(wcs0) + 1)); // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: comparison length is too long and might lead to a buffer overflow [bugprone-not-null-terminated-result] - // CHECK-FIXES: wcsncmp(wcs0, wcs1, (wcslen(wcs0))); + // CHECK-FIXES: return wcsncmp(wcs0, wcs1, (wcslen(wcs0))); } int bad_wcsncmp_2(wchar_t *wcs2, const wchar_t *wcs3) { return wcsncmp(wcs2, wcs3, 1 + wcslen(wcs2)); // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: comparison length is too long and might lead to a buffer overflow [bugprone-not-null-terminated-result] - // CHECK-FIXES: wcsncmp(wcs2, wcs3, wcslen(wcs2)); + // CHECK-FIXES: return wcsncmp(wcs2, wcs3, wcslen(wcs2)); } int good_wcsncmp_1_2(wchar_t *wcs4, const wchar_t *wcs5) { @@ -74,7 +74,7 @@ int good_wcsncmp_1_2(wchar_t *wcs4, const wchar_t *wcs5) { int bad_wcsncmp_3(wchar_t *wcs6) { return wcsncmp(wcs6, L"string", 7); // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: comparison length is too long and might lead to a buffer overflow [bugprone-not-null-terminated-result] - // CHECK-FIXES: wcsncmp(wcs6, L"string", 6); + // CHECK-FIXES: return wcsncmp(wcs6, L"string", 6); } int good_wcsncmp_3(wchar_t *wcs7) { diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/posix-return.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/posix-return.cpp index 8db0536..d0dfd97 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/posix-return.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/posix-return.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes %s bugprone-posix-return %t +// RUN: %check_clang_tidy %s bugprone-posix-return %t #define NULL nullptr #define ZERO 0 @@ -43,40 +43,40 @@ extern "C" int pthread_yield(void); void warningLessThanZero() { if (posix_fadvise(0, 0, 0, 0) < 0) {} // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: the comparison always evaluates to false because posix_fadvise always returns non-negative values - // CHECK-FIXES: posix_fadvise(0, 0, 0, 0) > 0 + // CHECK-FIXES: if (posix_fadvise(0, 0, 0, 0) > 0) {} if (posix_fallocate(0, 0, 0) < 0) {} // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: - // CHECK-FIXES: posix_fallocate(0, 0, 0) > 0 + // CHECK-FIXES: if (posix_fallocate(0, 0, 0) > 0) {} if (posix_madvise(NULL, 0, 0) < 0) {} // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: - // CHECK-FIXES: posix_madvise(NULL, 0, 0) > 0 + // CHECK-FIXES: if (posix_madvise(NULL, 0, 0) > 0) {} if (posix_memalign(NULL, 0, 0) < 0) {} // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: - // CHECK-FIXES: posix_memalign(NULL, 0, 0) > 0 + // CHECK-FIXES: if (posix_memalign(NULL, 0, 0) > 0) {} if (posix_spawn(NULL, NULL, NULL, NULL, {NULL}, {NULL}) < 0) {} // CHECK-MESSAGES: :[[@LINE-1]]:59: warning: - // CHECK-FIXES: posix_spawn(NULL, NULL, NULL, NULL, {NULL}, {NULL}) > 0 + // CHECK-FIXES: if (posix_spawn(NULL, NULL, NULL, NULL, {NULL}, {NULL}) > 0) {} if (posix_spawnp(NULL, NULL, NULL, NULL, {NULL}, {NULL}) < 0) {} // CHECK-MESSAGES: :[[@LINE-1]]:60: warning: - // CHECK-FIXES: posix_spawnp(NULL, NULL, NULL, NULL, {NULL}, {NULL}) > 0 + // CHECK-FIXES: if (posix_spawnp(NULL, NULL, NULL, NULL, {NULL}, {NULL}) > 0) {} if (pthread_create(NULL, NULL, NULL, NULL) < 0) {} // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: the comparison always evaluates to false because pthread_create always returns non-negative values - // CHECK-FIXES: pthread_create(NULL, NULL, NULL, NULL) > 0 + // CHECK-FIXES: if (pthread_create(NULL, NULL, NULL, NULL) > 0) {} if (pthread_attr_setaffinity_np(NULL, 0, NULL) < 0) {} // CHECK-MESSAGES: :[[@LINE-1]]:50: warning: - // CHECK-FIXES: pthread_attr_setaffinity_np(NULL, 0, NULL) > 0 + // CHECK-FIXES: if (pthread_attr_setaffinity_np(NULL, 0, NULL) > 0) {} if (pthread_attr_setschedpolicy(NULL, 0) < 0) {} // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: - // CHECK-FIXES: pthread_attr_setschedpolicy(NULL, 0) > 0) + // CHECK-FIXES: if (pthread_attr_setschedpolicy(NULL, 0) > 0) {} if (pthread_attr_init(NULL) < 0) {} // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: - // CHECK-FIXES: pthread_attr_init(NULL) > 0 + // CHECK-FIXES: if (pthread_attr_init(NULL) > 0) {} if (pthread_yield() < 0) {} // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: - // CHECK-FIXES: pthread_yield() > 0 - if (0 > pthread_yield() ) {} + // CHECK-FIXES: if (pthread_yield() > 0) {} + if (0 > pthread_yield()) {} // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: - // CHECK-FIXES: 0 < pthread_yield() + // CHECK-FIXES: if (0 < pthread_yield()) {} } @@ -137,7 +137,7 @@ void warningEqualsNegative() { void WarningWithMacro() { if (posix_fadvise(0, 0, 0, 0) < ZERO) {} // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: - // CHECK-FIXES: posix_fadvise(0, 0, 0, 0) > ZERO + // CHECK-FIXES: if (posix_fadvise(0, 0, 0, 0) > ZERO) {} if (posix_fadvise(0, 0, 0, 0) >= ZERO) {} // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: if (posix_fadvise(0, 0, 0, 0) == NEGATIVE_ONE) {} @@ -150,7 +150,7 @@ void WarningWithMacro() { // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: if (pthread_create(NULL, NULL, NULL, NULL) < ZERO) {} // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: - // CHECK-FIXES: pthread_create(NULL, NULL, NULL, NULL) > ZERO + // CHECK-FIXES: if (pthread_create(NULL, NULL, NULL, NULL) > ZERO) {} if (pthread_create(NULL, NULL, NULL, NULL) >= ZERO) {} // CHECK-MESSAGES: :[[@LINE-1]]:46: warning: if (pthread_create(NULL, NULL, NULL, NULL) == NEGATIVE_ONE) {} diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/stringview-nullptr.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/stringview-nullptr.cpp index 050e38d..b85ba02 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/stringview-nullptr.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/stringview-nullptr.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes %s bugprone-stringview-nullptr -std=c++17 %t +// RUN: %check_clang_tidy %s bugprone-stringview-nullptr -std=c++17 %t namespace std { @@ -148,7 +148,8 @@ void temporary_construction() /* a */ { // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default // CHECK-FIXES: (void)(std::string_view()) /* a4 */; - (void)(std::string_view({})) /* a5 */; // Default `const CharT*` + // Default `const CharT*` + (void)(std::string_view({})) /* a5 */; // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default // CHECK-FIXES: (void)(std::string_view()) /* a5 */; } @@ -171,7 +172,8 @@ void temporary_construction() /* a */ { // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default // CHECK-FIXES: (void)(std::string_view{}) /* a9 */; - (void)(std::string_view{{}}) /* a10 */; // Default `const CharT*` + // Default `const CharT*` + (void)(std::string_view{{}}) /* a10 */; // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default // CHECK-FIXES: (void)(std::string_view{}) /* a10 */; } @@ -202,7 +204,8 @@ void temporary_construction() /* a */ { // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default // CHECK-FIXES: (void)((std::string_view){}) /* a16 */; - (void)((std::string_view){{}}) /* a17 */; // Default `const CharT*` + // Default `const CharT*` + (void)((std::string_view){{}}) /* a17 */; // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: constructing{{.*}}default // CHECK-FIXES: (void)((std::string_view){}) /* a17 */; @@ -230,7 +233,8 @@ void temporary_construction() /* a */ { // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default // CHECK-FIXES: (void)((const std::string_view){}) /* a23 */; - (void)((const std::string_view){{}}) /* a24 */; // Default `const CharT*` + // Default `const CharT*` + (void)((const std::string_view){{}}) /* a24 */; // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default // CHECK-FIXES: (void)((const std::string_view){}) /* a24 */; } @@ -316,7 +320,8 @@ void stack_construction() /* b */ { // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default // CHECK-FIXES: std::string_view b13 = {}; - std::string_view b14 = {{}}; // Default `const CharT*` + // Default `const CharT*` + std::string_view b14 = {{}}; // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default // CHECK-FIXES: std::string_view b14 = {}; @@ -336,7 +341,8 @@ void stack_construction() /* b */ { // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default // CHECK-FIXES: const std::string_view b18 = {}; - const std::string_view b19 = {{}}; // Default `const CharT*` + // Default `const CharT*` + const std::string_view b19 = {{}}; // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default // CHECK-FIXES: const std::string_view b19 = {}; } @@ -382,7 +388,8 @@ void stack_construction() /* b */ { // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: constructing{{.*}}default // CHECK-FIXES: std::string_view b28; - std::string_view b29({}); // Default `const CharT*` + // Default `const CharT*` + std::string_view b29({}); // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: constructing{{.*}}default // CHECK-FIXES: std::string_view b29; @@ -402,7 +409,8 @@ void stack_construction() /* b */ { // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: constructing{{.*}}default // CHECK-FIXES: const std::string_view b33; - const std::string_view b34({}); // Default `const CharT*` + // Default `const CharT*` + const std::string_view b34({}); // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: constructing{{.*}}default // CHECK-FIXES: const std::string_view b34; } @@ -448,7 +456,8 @@ void stack_construction() /* b */ { // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default // CHECK-FIXES: std::string_view b43{}; - std::string_view b44{{}}; // Default `const CharT*` + // Default `const CharT*` + std::string_view b44{{}}; // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default // CHECK-FIXES: std::string_view b44{}; @@ -468,7 +477,8 @@ void stack_construction() /* b */ { // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default // CHECK-FIXES: const std::string_view b48{}; - const std::string_view b49{{}}; // Default `const CharT*` + // Default `const CharT*` + const std::string_view b49{{}}; // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default // CHECK-FIXES: const std::string_view b49{}; } @@ -557,7 +567,8 @@ void field_construction() /* c */ { // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default // CHECK-FIXES: std::string_view c13 = {}; - std::string_view c14 = {{}}; // Default `const CharT*` + // Default `const CharT*` + std::string_view c14 = {{}}; // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: constructing{{.*}}default // CHECK-FIXES: std::string_view c14 = {}; @@ -577,7 +588,8 @@ void field_construction() /* c */ { // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default // CHECK-FIXES: const std::string_view c18 = {}; - const std::string_view c19 = {{}}; // Default `const CharT*` + // Default `const CharT*` + const std::string_view c19 = {{}}; // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: constructing{{.*}}default // CHECK-FIXES: const std::string_view c19 = {}; }; @@ -621,7 +633,8 @@ void field_construction() /* c */ { // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default // CHECK-FIXES: std::string_view c28{}; - std::string_view c29{{}}; // Default `const CharT*` + // Default `const CharT*` + std::string_view c29{{}}; // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: constructing{{.*}}default // CHECK-FIXES: std::string_view c29{}; @@ -641,7 +654,8 @@ void field_construction() /* c */ { // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default // CHECK-FIXES: const std::string_view c33{}; - const std::string_view c34{{}}; // Default `const CharT*` + // Default `const CharT*` + const std::string_view c34{{}}; // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: constructing{{.*}}default // CHECK-FIXES: const std::string_view c34{}; }; @@ -694,7 +708,8 @@ void field_construction() /* c */ { // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default // CHECK-FIXES: c43(), - c44({}) { // Default `const CharT*` + // Default `const CharT*` + c44({}) { // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default // CHECK-FIXES: c44() { } @@ -754,7 +769,8 @@ void field_construction() /* c */ { // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default // CHECK-FIXES: c53{}, - c54{{}} { // Default `const CharT*` + // Default `const CharT*` + c54{{}} { // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: constructing{{.*}}default // CHECK-FIXES: c54{} { } @@ -852,7 +868,8 @@ void default_argument_construction() /* d */ { // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default // CHECK-FIXES: void d13(std::string_view sv = {}); - void d14(std::string_view sv = {{}}); // Default `const CharT*` + // Default `const CharT*` + void d14(std::string_view sv = {{}}); // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: constructing{{.*}}default // CHECK-FIXES: void d14(std::string_view sv = {}); @@ -872,7 +889,8 @@ void default_argument_construction() /* d */ { // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default // CHECK-FIXES: void d18(const std::string_view sv = {}); - void d19(const std::string_view sv = {{}}); // Default `const CharT*` + // Default `const CharT*` + void d19(const std::string_view sv = {{}}); // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: constructing{{.*}}default // CHECK-FIXES: void d19(const std::string_view sv = {}); } @@ -920,7 +938,8 @@ void heap_construction() /* e */ { // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default // CHECK-FIXES: (void)(new std::string_view()) /* e4 */; - (void)(new std::string_view({})) /* e5 */; // Default `const CharT*` + // Default `const CharT*` + (void)(new std::string_view({})) /* e5 */; // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default // CHECK-FIXES: (void)(new std::string_view()) /* e5 */; @@ -940,7 +959,8 @@ void heap_construction() /* e */ { // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default // CHECK-FIXES: (void)(new const std::string_view()) /* e9 */; - (void)(new const std::string_view({})) /* e10 */; // Default `const CharT*` + // Default `const CharT*` + (void)(new const std::string_view({})) /* e10 */; // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default // CHECK-FIXES: (void)(new const std::string_view()) /* e10 */; } @@ -986,7 +1006,8 @@ void heap_construction() /* e */ { // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default // CHECK-FIXES: (void)(new std::string_view{}) /* e19 */; - (void)(new std::string_view{{}}) /* e20 */; // Default `const CharT*` + // Default `const CharT*` + (void)(new std::string_view{{}}) /* e20 */; // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: constructing{{.*}}default // CHECK-FIXES: (void)(new std::string_view{}) /* e20 */; @@ -1006,7 +1027,8 @@ void heap_construction() /* e */ { // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default // CHECK-FIXES: (void)(new const std::string_view{}) /* e24 */; - (void)(new const std::string_view{{}}) /* e25 */; // Default `const CharT*` + // Default `const CharT*` + (void)(new const std::string_view{{}}) /* e25 */; // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: constructing{{.*}}default // CHECK-FIXES: (void)(new const std::string_view{}) /* e25 */; } @@ -1054,7 +1076,8 @@ void function_argument_initialization() /* f */ { // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: passing{{.*}}empty string // CHECK-FIXES: function("") /* f4 */; - function({{}}) /* f5 */; // Default `const CharT*` + // Default `const CharT*` + function({{}}) /* f5 */; // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: passing{{.*}}empty string // CHECK-FIXES: function("") /* f5 */; } @@ -1102,7 +1125,8 @@ void assignment(std::string_view sv) /* g */ { // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: assignment{{.*}}default // CHECK-FIXES: sv = {} /* g4 */; - sv = {{}} /* g5 */; // Default `const CharT*` + // Default `const CharT*` + sv = {{}} /* g5 */; // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: assignment{{.*}}default // CHECK-FIXES: sv = {} /* g5 */; } @@ -1150,7 +1174,8 @@ void pointer_assignment(std::string_view *sv_ptr) /* h */ { // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: assignment{{.*}}default // CHECK-FIXES: *sv_ptr = {} /* h4 */; - *sv_ptr = {{}} /* h5 */; // Default `const CharT*` + // Default `const CharT*` + *sv_ptr = {{}} /* h5 */; // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: assignment{{.*}}default // CHECK-FIXES: *sv_ptr = {} /* h5 */; } @@ -1566,7 +1591,8 @@ void return_statement() /* q */ { // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing{{.*}}default // CHECK-FIXES: []() -> SV { return {}; } /* q6 */; - []() -> SV { return {{}}; } /* q7 */; // Default `const CharT*` + // Default `const CharT*` + []() -> SV { return {{}}; } /* q7 */; // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: constructing{{.*}}default // CHECK-FIXES: []() -> SV { return {}; } /* q7 */; } diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-string-compare.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-string-compare.cpp index d670fa9..399018e 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-string-compare.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-string-compare.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes %s bugprone-suspicious-string-compare %t -- \ +// RUN: %check_clang_tidy %s bugprone-suspicious-string-compare %t -- \ // RUN: -config='{CheckOptions: \ // RUN: {bugprone-suspicious-string-compare.WarnOnImplicitComparison: true, \ // RUN: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison: true}}' \ @@ -117,187 +117,187 @@ int test_implicit_compare_with_functions() { if (memcmp(A, "a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'memcmp' is called without explicitly comparing result - // CHECK-FIXES: memcmp(A, "a", 1) != 0) + // CHECK-FIXES: if (memcmp(A, "a", 1) != 0) if (wmemcmp(W, L"a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wmemcmp' is called without explicitly comparing result - // CHECK-FIXES: wmemcmp(W, L"a", 1) != 0) + // CHECK-FIXES: if (wmemcmp(W, L"a", 1) != 0) if (memicmp(A, "a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'memicmp' is called without explicitly comparing result - // CHECK-FIXES: memicmp(A, "a", 1) != 0) + // CHECK-FIXES: if (memicmp(A, "a", 1) != 0) if (_memicmp(A, "a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_memicmp' is called without explicitly comparing result - // CHECK-FIXES: _memicmp(A, "a", 1) != 0) + // CHECK-FIXES: if (_memicmp(A, "a", 1) != 0) if (_memicmp_l(A, "a", 1, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_memicmp_l' is called without explicitly comparing result - // CHECK-FIXES: _memicmp_l(A, "a", 1, locale) != 0) + // CHECK-FIXES: if (_memicmp_l(A, "a", 1, locale) != 0) if (strcmp(A, "a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmp' is called without explicitly comparing result - // CHECK-FIXES: strcmp(A, "a") != 0) + // CHECK-FIXES: if (strcmp(A, "a") != 0) if (strncmp(A, "a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strncmp' is called without explicitly comparing result - // CHECK-FIXES: strncmp(A, "a", 1) != 0) + // CHECK-FIXES: if (strncmp(A, "a", 1) != 0) if (strcasecmp(A, "a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcasecmp' is called without explicitly comparing result - // CHECK-FIXES: strcasecmp(A, "a") != 0) + // CHECK-FIXES: if (strcasecmp(A, "a") != 0) if (strncasecmp(A, "a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strncasecmp' is called without explicitly comparing result - // CHECK-FIXES: strncasecmp(A, "a", 1) != 0) + // CHECK-FIXES: if (strncasecmp(A, "a", 1) != 0) if (stricmp(A, "a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'stricmp' is called without explicitly comparing result - // CHECK-FIXES: stricmp(A, "a") != 0) + // CHECK-FIXES: if (stricmp(A, "a") != 0) if (strcmpi(A, "a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strcmpi' is called without explicitly comparing result - // CHECK-FIXES: strcmpi(A, "a") != 0) + // CHECK-FIXES: if (strcmpi(A, "a") != 0) if (_stricmp(A, "a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_stricmp' is called without explicitly comparing result - // CHECK-FIXES: _stricmp(A, "a") != 0) + // CHECK-FIXES: if (_stricmp(A, "a") != 0) if (strnicmp(A, "a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'strnicmp' is called without explicitly comparing result - // CHECK-FIXES: strnicmp(A, "a", 1) != 0) + // CHECK-FIXES: if (strnicmp(A, "a", 1) != 0) if (_strnicmp(A, "a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_strnicmp' is called without explicitly comparing result - // CHECK-FIXES: _strnicmp(A, "a", 1) != 0) + // CHECK-FIXES: if (_strnicmp(A, "a", 1) != 0) if (_stricmp_l(A, "a", locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_stricmp_l' is called without explicitly comparing result - // CHECK-FIXES: _stricmp_l(A, "a", locale) != 0) + // CHECK-FIXES: if (_stricmp_l(A, "a", locale) != 0) if (_strnicmp_l(A, "a", 1, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_strnicmp_l' is called without explicitly comparing result - // CHECK-FIXES: _strnicmp_l(A, "a", 1, locale) != 0) + // CHECK-FIXES: if (_strnicmp_l(A, "a", 1, locale) != 0) if (wcscmp(W, L"a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcscmp' is called without explicitly comparing result - // CHECK-FIXES: wcscmp(W, L"a") != 0) + // CHECK-FIXES: if (wcscmp(W, L"a") != 0) if (wcsncmp(W, L"a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcsncmp' is called without explicitly comparing result - // CHECK-FIXES: wcsncmp(W, L"a", 1) != 0) + // CHECK-FIXES: if (wcsncmp(W, L"a", 1) != 0) if (wcscasecmp(W, L"a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcscasecmp' is called without explicitly comparing result - // CHECK-FIXES: wcscasecmp(W, L"a") != 0) + // CHECK-FIXES: if (wcscasecmp(W, L"a") != 0) if (wcsicmp(W, L"a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcsicmp' is called without explicitly comparing result - // CHECK-FIXES: wcsicmp(W, L"a") != 0) + // CHECK-FIXES: if (wcsicmp(W, L"a") != 0) if (_wcsicmp(W, L"a")) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_wcsicmp' is called without explicitly comparing result - // CHECK-FIXES: _wcsicmp(W, L"a") != 0) + // CHECK-FIXES: if (_wcsicmp(W, L"a") != 0) if (_wcsicmp_l(W, L"a", locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_wcsicmp_l' is called without explicitly comparing result - // CHECK-FIXES: _wcsicmp_l(W, L"a", locale) != 0) + // CHECK-FIXES: if (_wcsicmp_l(W, L"a", locale) != 0) if (wcsnicmp(W, L"a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function 'wcsnicmp' is called without explicitly comparing result - // CHECK-FIXES: wcsnicmp(W, L"a", 1) != 0) + // CHECK-FIXES: if (wcsnicmp(W, L"a", 1) != 0) if (_wcsnicmp(W, L"a", 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_wcsnicmp' is called without explicitly comparing result - // CHECK-FIXES: _wcsnicmp(W, L"a", 1) != 0) + // CHECK-FIXES: if (_wcsnicmp(W, L"a", 1) != 0) if (_wcsnicmp_l(W, L"a", 1, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_wcsnicmp_l' is called without explicitly comparing result - // CHECK-FIXES: _wcsnicmp_l(W, L"a", 1, locale) != 0) + // CHECK-FIXES: if (_wcsnicmp_l(W, L"a", 1, locale) != 0) if (_mbscmp(U, V)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbscmp' is called without explicitly comparing result - // CHECK-FIXES: _mbscmp(U, V) != 0) + // CHECK-FIXES: if (_mbscmp(U, V) != 0) if (_mbsncmp(U, V, 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsncmp' is called without explicitly comparing result - // CHECK-FIXES: _mbsncmp(U, V, 1) != 0) + // CHECK-FIXES: if (_mbsncmp(U, V, 1) != 0) if (_mbsnbcmp(U, V, 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnbcmp' is called without explicitly comparing result - // CHECK-FIXES: _mbsnbcmp(U, V, 1) != 0) + // CHECK-FIXES: if (_mbsnbcmp(U, V, 1) != 0) if (_mbsnbicmp(U, V, 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnbicmp' is called without explicitly comparing result - // CHECK-FIXES: _mbsnbicmp(U, V, 1) != 0) + // CHECK-FIXES: if (_mbsnbicmp(U, V, 1) != 0) if (_mbsicmp(U, V)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsicmp' is called without explicitly comparing result - // CHECK-FIXES: _mbsicmp(U, V) != 0) + // CHECK-FIXES: if (_mbsicmp(U, V) != 0) if (_mbsnicmp(U, V, 1)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnicmp' is called without explicitly comparing result - // CHECK-FIXES: _mbsnicmp(U, V, 1) != 0) + // CHECK-FIXES: if (_mbsnicmp(U, V, 1) != 0) if (_mbscmp_l(U, V, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbscmp_l' is called without explicitly comparing result - // CHECK-FIXES: _mbscmp_l(U, V, locale) != 0) + // CHECK-FIXES: if (_mbscmp_l(U, V, locale) != 0) if (_mbsncmp_l(U, V, 1, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsncmp_l' is called without explicitly comparing result - // CHECK-FIXES: _mbsncmp_l(U, V, 1, locale) != 0) + // CHECK-FIXES: if (_mbsncmp_l(U, V, 1, locale) != 0) if (_mbsicmp_l(U, V, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsicmp_l' is called without explicitly comparing result - // CHECK-FIXES: _mbsicmp_l(U, V, locale) != 0) + // CHECK-FIXES: if (_mbsicmp_l(U, V, locale) != 0) if (_mbsnicmp_l(U, V, 1, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnicmp_l' is called without explicitly comparing result - // CHECK-FIXES: _mbsnicmp_l(U, V, 1, locale) != 0) + // CHECK-FIXES: if (_mbsnicmp_l(U, V, 1, locale) != 0) if (_mbsnbcmp_l(U, V, 1, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnbcmp_l' is called without explicitly comparing result - // CHECK-FIXES: _mbsnbcmp_l(U, V, 1, locale) != 0) + // CHECK-FIXES: if (_mbsnbcmp_l(U, V, 1, locale) != 0) if (_mbsnbicmp_l(U, V, 1, locale)) return 0; // CHECK-MESSAGES: [[@LINE-2]]:7: warning: function '_mbsnbicmp_l' is called without explicitly comparing result - // CHECK-FIXES: _mbsnbicmp_l(U, V, 1, locale) != 0) + // CHECK-FIXES: if (_mbsnbicmp_l(U, V, 1, locale) != 0) return 1; } diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/swapped-arguments.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/swapped-arguments.cpp index 3d21396..985ebc2 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/swapped-arguments.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/swapped-arguments.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes %s bugprone-swapped-arguments %t +// RUN: %check_clang_tidy %s bugprone-swapped-arguments %t void F(int, double); @@ -9,7 +9,7 @@ void G(T a, U b) { F(a, b); // no-warning F(2.0, 4); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'double' to 'int' followed by argument converted from 'int' to 'double', potentially swapped arguments. -// CHECK-FIXES: F(4, 2.0) +// CHECK-FIXES: F(4, 2.0); } void funShortFloat(short, float); @@ -20,7 +20,7 @@ void funBoolFloat(bool, float); void foo() { F(1.0, 3); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: argument with implicit conversion from 'double' to 'int' followed by argument converted from 'int' to 'double', potentially swapped arguments. -// CHECK-FIXES: F(3, 1.0) +// CHECK-FIXES: F(3, 1.0); #define M(x, y) x##y() |