-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang-tidy][NFC] Migrate tests away from --match-partial-fixes
#162851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-clang-tools-extra @llvm/pr-subscribers-clang-tidy Author: Victor Chernyakin (localspook) ChangesFollow up to #162293. Now the question is: do we want to remove the Most of the changes are mechanical, but see my comments on the interesting ones. Patch is 296.35 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/162851.diff 81 Files Affected:
diff --git a/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-addition.cpp b/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-addition.cpp
index 562b513d784e6..cc41603394427 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-addition.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-addition.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy --match-partial-fixes %s abseil-duration-addition %t -- -- -I%S/Inputs
+// RUN: %check_clang_tidy %s abseil-duration-addition %t -- -- -I%S/Inputs
#include "absl/time/time.h"
@@ -8,68 +8,68 @@ void f() {
i = absl::ToUnixHours(t) + 5;
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixHours(t + absl::Hours(5))
+ // CHECK-FIXES: i = absl::ToUnixHours(t + absl::Hours(5));
i = absl::ToUnixMinutes(t) + 5;
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixMinutes(t + absl::Minutes(5))
+ // CHECK-FIXES: i = absl::ToUnixMinutes(t + absl::Minutes(5));
i = absl::ToUnixSeconds(t) + 5;
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixSeconds(t + absl::Seconds(5))
+ // CHECK-FIXES: i = absl::ToUnixSeconds(t + absl::Seconds(5));
i = absl::ToUnixMillis(t) + 5;
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixMillis(t + absl::Milliseconds(5))
+ // CHECK-FIXES: i = absl::ToUnixMillis(t + absl::Milliseconds(5));
i = absl::ToUnixMicros(t) + 5;
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixMicros(t + absl::Microseconds(5))
+ // CHECK-FIXES: i = absl::ToUnixMicros(t + absl::Microseconds(5));
i = absl::ToUnixNanos(t) + 5;
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixNanos(t + absl::Nanoseconds(5))
+ // CHECK-FIXES: i = absl::ToUnixNanos(t + absl::Nanoseconds(5));
i = 3 + absl::ToUnixHours(t);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixHours(absl::Hours(3) + t)
+ // CHECK-FIXES: i = absl::ToUnixHours(absl::Hours(3) + t);
i = 3 + absl::ToUnixMinutes(t);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixMinutes(absl::Minutes(3) + t)
+ // CHECK-FIXES: i = absl::ToUnixMinutes(absl::Minutes(3) + t);
i = 3 + absl::ToUnixSeconds(t);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixSeconds(absl::Seconds(3) + t)
+ // CHECK-FIXES: i = absl::ToUnixSeconds(absl::Seconds(3) + t);
i = 3 + absl::ToUnixMillis(t);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixMillis(absl::Milliseconds(3) + t)
+ // CHECK-FIXES: i = absl::ToUnixMillis(absl::Milliseconds(3) + t);
i = 3 + absl::ToUnixMicros(t);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixMicros(absl::Microseconds(3) + t)
+ // CHECK-FIXES: i = absl::ToUnixMicros(absl::Microseconds(3) + t);
i = 3 + absl::ToUnixNanos(t);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixNanos(absl::Nanoseconds(3) + t)
+ // CHECK-FIXES: i = absl::ToUnixNanos(absl::Nanoseconds(3) + t);
// Undoing inverse conversions
i = absl::ToUnixMicros(t) + absl::ToInt64Microseconds(absl::Seconds(1));
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixMicros(t + absl::Seconds(1))
+ // CHECK-FIXES: i = absl::ToUnixMicros(t + absl::Seconds(1));
// Parens
i = 3 + (absl::ToUnixHours(t));
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixHours(absl::Hours(3) + t)
+ // CHECK-FIXES: i = absl::ToUnixHours(absl::Hours(3) + t);
// Float folding
i = absl::ToUnixSeconds(t) + 5.0;
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixSeconds(t + absl::Seconds(5))
+ // CHECK-FIXES: i = absl::ToUnixSeconds(t + absl::Seconds(5));
// We can rewrite the argument of the duration conversion
#define THIRTY absl::FromUnixSeconds(30)
i = absl::ToUnixSeconds(THIRTY) + 1;
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixSeconds(THIRTY + absl::Seconds(1))
+ // CHECK-FIXES: i = absl::ToUnixSeconds(THIRTY + absl::Seconds(1));
#undef THIRTY
// Some other contexts
if (absl::ToUnixSeconds(t) + 1.0 > 10) {}
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixSeconds(t + absl::Seconds(1))
+ // CHECK-FIXES: if (absl::ToUnixSeconds(t + absl::Seconds(1)) > 10) {}
// These should not match
i = 5 + 6;
@@ -88,7 +88,7 @@ template<typename T>
void foo(absl::Time t) {
int i = absl::ToUnixNanos(t) + T{};
// CHECK-MESSAGES: [[@LINE-1]]:11: warning: perform addition in the duration domain [abseil-duration-addition]
- // CHECK-FIXES: absl::ToUnixNanos(t + absl::Nanoseconds(T{}))
+ // CHECK-FIXES: int i = absl::ToUnixNanos(t + absl::Nanoseconds(T{}));
}
void g() {
diff --git a/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-comparison.cpp b/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-comparison.cpp
index 6110dfded6bac..8f49e71de1242 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-comparison.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-comparison.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy --match-partial-fixes %s abseil-duration-comparison %t -- -- -I%S/Inputs
+// RUN: %check_clang_tidy %s abseil-duration-comparison %t -- -- -I%S/Inputs
#include "absl/time/time.h"
@@ -11,104 +11,104 @@ void f() {
// Check against the RHS
b = x > absl::ToDoubleSeconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Seconds(x) > d1;
+ // CHECK-FIXES: b = absl::Seconds(x) > d1;
b = x >= absl::ToDoubleSeconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Seconds(x) >= d1;
+ // CHECK-FIXES: b = absl::Seconds(x) >= d1;
b = x == absl::ToDoubleSeconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Seconds(x) == d1;
+ // CHECK-FIXES: b = absl::Seconds(x) == d1;
b = x <= absl::ToDoubleSeconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Seconds(x) <= d1;
+ // CHECK-FIXES: b = absl::Seconds(x) <= d1;
b = x < absl::ToDoubleSeconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Seconds(x) < d1;
+ // CHECK-FIXES: b = absl::Seconds(x) < d1;
b = x == absl::ToDoubleSeconds(t1 - t2);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Seconds(x) == t1 - t2;
+ // CHECK-FIXES: b = absl::Seconds(x) == t1 - t2;
b = absl::ToDoubleSeconds(d1) > absl::ToDoubleSeconds(d2);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: d1 > d2;
+ // CHECK-FIXES: b = d1 > d2;
// Check against the LHS
b = absl::ToDoubleSeconds(d1) < x;
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: d1 < absl::Seconds(x);
+ // CHECK-FIXES: b = d1 < absl::Seconds(x);
b = absl::ToDoubleSeconds(d1) <= x;
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: d1 <= absl::Seconds(x);
+ // CHECK-FIXES: b = d1 <= absl::Seconds(x);
b = absl::ToDoubleSeconds(d1) == x;
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: d1 == absl::Seconds(x);
+ // CHECK-FIXES: b = d1 == absl::Seconds(x);
b = absl::ToDoubleSeconds(d1) >= x;
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: d1 >= absl::Seconds(x);
+ // CHECK-FIXES: b = d1 >= absl::Seconds(x);
b = absl::ToDoubleSeconds(d1) > x;
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: d1 > absl::Seconds(x);
+ // CHECK-FIXES: b = d1 > absl::Seconds(x);
// Comparison against zero
b = absl::ToDoubleSeconds(d1) < 0.0;
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: d1 < absl::ZeroDuration();
+ // CHECK-FIXES: b = d1 < absl::ZeroDuration();
b = absl::ToDoubleSeconds(d1) < 0;
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: d1 < absl::ZeroDuration();
+ // CHECK-FIXES: b = d1 < absl::ZeroDuration();
// Scales other than Seconds
b = x > absl::ToDoubleMicroseconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Microseconds(x) > d1;
+ // CHECK-FIXES: b = absl::Microseconds(x) > d1;
b = x >= absl::ToDoubleMilliseconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Milliseconds(x) >= d1;
+ // CHECK-FIXES: b = absl::Milliseconds(x) >= d1;
b = x == absl::ToDoubleNanoseconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Nanoseconds(x) == d1;
+ // CHECK-FIXES: b = absl::Nanoseconds(x) == d1;
b = x <= absl::ToDoubleMinutes(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Minutes(x) <= d1;
+ // CHECK-FIXES: b = absl::Minutes(x) <= d1;
b = x < absl::ToDoubleHours(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Hours(x) < d1;
+ // CHECK-FIXES: b = absl::Hours(x) < d1;
// Integer comparisons
b = x > absl::ToInt64Microseconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Microseconds(x) > d1;
+ // CHECK-FIXES: b = absl::Microseconds(x) > d1;
b = x >= absl::ToInt64Milliseconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Milliseconds(x) >= d1;
+ // CHECK-FIXES: b = absl::Milliseconds(x) >= d1;
b = x == absl::ToInt64Nanoseconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Nanoseconds(x) == d1;
+ // CHECK-FIXES: b = absl::Nanoseconds(x) == d1;
b = x == absl::ToInt64Seconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Seconds(x) == d1;
+ // CHECK-FIXES: b = absl::Seconds(x) == d1;
b = x <= absl::ToInt64Minutes(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Minutes(x) <= d1;
+ // CHECK-FIXES: b = absl::Minutes(x) <= d1;
b = x < absl::ToInt64Hours(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Hours(x) < d1;
+ // CHECK-FIXES: b = absl::Hours(x) < d1;
// Other abseil-duration checks folded into this one
b = static_cast<double>(5) > absl::ToDoubleSeconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Seconds(5) > d1;
+ // CHECK-FIXES: b = absl::Seconds(5) > d1;
b = double(5) > absl::ToDoubleSeconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Seconds(5) > d1;
+ // CHECK-FIXES: b = absl::Seconds(5) > d1;
b = float(5) > absl::ToDoubleSeconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Seconds(5) > d1;
+ // CHECK-FIXES: b = absl::Seconds(5) > d1;
b = ((double)5) > absl::ToDoubleSeconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Seconds(5) > d1;
+ // CHECK-FIXES: b = absl::Seconds(5) > d1;
b = 5.0 > absl::ToDoubleSeconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Seconds(5) > d1;
+ // CHECK-FIXES: b = absl::Seconds(5) > d1;
// A long expression
bool some_condition;
@@ -125,20 +125,20 @@ void f() {
int y;
b = (y + 5) * 10 > absl::ToDoubleMilliseconds(d1);
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: absl::Milliseconds((y + 5) * 10) > d1;
+ // CHECK-FIXES: b = absl::Milliseconds((y + 5) * 10) > d1;
// We should still transform the expression inside this macro invocation
#define VALUE_IF(v, e) v ? (e) : 0
int a = VALUE_IF(1, 5 > absl::ToDoubleSeconds(d1));
// CHECK-MESSAGES: [[@LINE-1]]:23: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: VALUE_IF(1, absl::Seconds(5) > d1);
+ // CHECK-FIXES: int a = VALUE_IF(1, absl::Seconds(5) > d1);
#undef VALUE_IF
#define VALUE_IF_2(e) (e)
#define VALUE_IF(v, e) v ? VALUE_IF_2(e) : VALUE_IF_2(0)
int a2 = VALUE_IF(1, 5 > absl::ToDoubleSeconds(d1));
// CHECK-MESSAGES: [[@LINE-1]]:24: warning: perform comparison in the duration domain [abseil-duration-comparison]
- // CHECK-FIXES: VALUE_IF(1, absl::Seconds(5) > d1);
+ // CHECK-FIXES: int a2 = VALUE_IF(1, absl::Seconds(5) > d1);
#undef VALUE_IF
#undef VALUE_IF_2
diff --git a/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-conversion-cast.cpp b/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-conversion-cast.cpp
index 368b9d63e0ec7..b5183a98e0f2d 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-conversion-cast.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-conversion-cast.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy --match-partial-fixes %s abseil-duration-conversion-cast %t -- -- -I%S/Inputs
+// RUN: %check_clang_tidy %s abseil-duration-conversion-cast %t -- -- -I%S/Inputs
#include "absl/time/time.h"
@@ -9,56 +9,56 @@ void f() {
i = static_cast<int>(absl::ToDoubleHours(d1));
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to an integer rather than through a type cast [abseil-duration-conversion-cast]
- // CHECK-FIXES: absl::ToInt64Hours(d1);
+ // CHECK-FIXES: i = absl::ToInt64Hours(d1);
x = static_cast<float>(absl::ToInt64Hours(d1));
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to a floating-point number rather than through a type cast [abseil-duration-conversion-cast]
- // CHECK-FIXES: absl::ToDoubleHours(d1);
+ // CHECK-FIXES: x = absl::ToDoubleHours(d1);
i = static_cast<int>(absl::ToDoubleMinutes(d1));
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to an integer rather than through a type cast [abseil-duration-conversion-cast]
- // CHECK-FIXES: absl::ToInt64Minutes(d1);
+ // CHECK-FIXES: i = absl::ToInt64Minutes(d1);
x = static_cast<float>(absl::ToInt64Minutes(d1));
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to a floating-point number rather than through a type cast [abseil-duration-conversion-cast]
- // CHECK-FIXES: absl::ToDoubleMinutes(d1);
+ // CHECK-FIXES: x = absl::ToDoubleMinutes(d1);
i = static_cast<int>(absl::ToDoubleSeconds(d1));
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to an integer rather than through a type cast [abseil-duration-conversion-cast]
- // CHECK-FIXES: absl::ToInt64Seconds(d1);
+ // CHECK-FIXES: i = absl::ToInt64Seconds(d1);
x = static_cast<float>(absl::ToInt64Seconds(d1));
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to a floating-point number rather than through a type cast [abseil-duration-conversion-cast]
- // CHECK-FIXES: absl::ToDoubleSeconds(d1);
+ // CHECK-FIXES: x = absl::ToDoubleSeconds(d1);
i = static_cast<int>(absl::ToDoubleMilliseconds(d1));
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to an integer rather than through a type cast [abseil-duration-conversion-cast]
- // CHECK-FIXES: absl::ToInt64Milliseconds(d1);
+ // CHECK-FIXES: i = absl::ToInt64Milliseconds(d1);
x = static_cast<float>(absl::ToInt64Milliseconds(d1));
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to a floating-point number rather than through a type cast [abseil-duration-conversion-cast]
- // CHECK-FIXES: absl::ToDoubleMilliseconds(d1);
+ // CHECK-FIXES: x = absl::ToDoubleMilliseconds(d1);
i = static_cast<int>(absl::ToDoubleMicroseconds(d1));
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to an integer rather than through a type cast [abseil-duration-conversion-cast]
- // CHECK-FIXES: absl::ToInt64Microseconds(d1);
+ // CHECK-FIXES: i = absl::ToInt64Microseconds(d1);
x = static_cast<float>(absl::ToInt64Microseconds(d1));
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to a floating-point number rather than through a type cast [abseil-duration-conversion-cast]
- // CHECK-FIXES: absl::ToDoubleMicroseconds(d1);
+ // CHECK-FIXES: x = absl::ToDoubleMicroseconds(d1);
i = static_cast<int>(absl::ToDoubleNanoseconds(d1));
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to an integer rather than through a type cast [abseil-duration-conversion-cast]
- // CHECK-FIXES: absl::ToInt64Nanoseconds(d1);
+ // CHECK-FIXES: i = absl::ToInt64Nanoseconds(d1);
x = static_cast<float>(absl::ToInt64Nanoseconds(d1));
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to a floating-point number rather than through a type cast [abseil-duration-conversion-cast]
- // CHECK-FIXES: absl::ToDoubleNanoseconds(d1);
+ // CHECK-FIXES: x = absl::ToDoubleNanoseconds(d1);
// Functional-style casts
i = int(absl::ToDoubleHours(d1));
// CHECK-MESSAGES: [[@LINE-1]]:7: warning: duration should be converted directly to an integer rather than through a type cast [abseil-duration-conversion-cast]
- // CHECK-FIXES: absl::ToInt64Hours(d1);
+ // CHECK-FIXES: i = absl::ToInt64Hours(d1);
x = float(absl::ToInt64Microseconds(d1));
// CHECK-MESSAGES: [[@LINE-1]...
[truncated]
|
for (;;) { | ||
do_something("for-ok"); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be moved down because otherwise the // CHECK-FIXES: for (;;) {
finds this loop, then the // CHECK-FIXES-NEXT: ;
fails (because it found the wrong loop).
//CHECK-MESSAGES: :[[@LINE+2]]:94: warning: '/' has higher precedence than '-'; add parentheses to explicitly specify the order of operations [readability-math-missing-parentheses] | ||
//CHECK-FIXES: int q = (1 MACRO_ADD (2 MACRO_MULTIPLY 3)) MACRO_OR ((4 MACRO_AND 5) MACRO_XOR (6 MACRO_SUBTRACT (7 MACRO_DIVIDE 8))); | ||
int q = 1 MACRO_ADD 2 MACRO_MULTIPLY 3 MACRO_OR 4 MACRO_AND 5 MACRO_XOR 6 MACRO_SUBTRACT 7 MACRO_DIVIDE 8; // No warning | ||
int q = 1 MACRO_ADD 2 MACRO_MULTIPLY 3 MACRO_OR 4 MACRO_AND 5 MACRO_XOR 6 MACRO_SUBTRACT 7 MACRO_DIVIDE 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes warning!
static_assert(v11 == 1, ""); | ||
|
||
static constexpr auto v12 = 1UL; // OK. | ||
static constexpr auto v12 = 1UL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment is wrong
a[i] = i; | ||
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not use array subscript when the index is not an integer constant expression | ||
// CHECK-FIXES: gsl::at(a, i) = i; | ||
gsl::at(a, i) = i; // OK, gsl::at() instead of [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This // CHECK-FIXES
shouldn't be here; cppcoreguidelines-pro-bounds-constant-array-index
only offers fixes when the GslHeader
option is specified, and that's tested in a different file. The only reason this worked is that it matches the following line.
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison] | ||
// CHECK-FIXES: if (q20::cmp_less(uArray[2],sArray[2])) | ||
// CHECK-FIXES: if (q20::cmp_less(uArray[2],sArray[2]))) | ||
// FIXME: There should only be 2 closing braces. The fix-it inserts an unbalanced one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woohoo, found a bug!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you create a bug ticket for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened #162981
// CHECK-FIXES: const Klazz<const int>* p5() const; | ||
|
||
const Clazz operator++(int x) { // p12 | ||
const Clazz operator++(int x) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't figure out what this comment is supposed to mean; I think it's safe to delete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I think it can benefit the quality.
I think we should keep it but maybe add some deprecated warning to avoid breaking downstream clang-tidy's test. |
Follow up to #162293.
Now the question is: do we want to remove the
--match-partial-fixes
option entirely? It could break downstream users ofcheck_clang_tidy.py
and force them to migrate; is that a reason to keep it around though?Most of the changes are mechanical, but see my comments on the interesting ones.