diff options
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/checkers/abseil')
11 files changed, 199 insertions, 199 deletions
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 562b513..cc41603 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 6110dfd..8f49e71 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 368b9d6..b5183a9 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]]: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); // C-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]]: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); // Type aliasing typedef int FancyInt; @@ -66,17 +66,17 @@ void f() { FancyInt j = static_cast<FancyInt>(absl::ToDoubleHours(d1)); // CHECK-MESSAGES: [[@LINE-1]]:16: 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: FancyInt j = absl::ToInt64Hours(d1); FancyFloat k = static_cast<FancyFloat>(absl::ToInt64Microseconds(d1)); // CHECK-MESSAGES: [[@LINE-1]]:18: 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: FancyFloat k = absl::ToDoubleMicroseconds(d1); // Macro handling // We want to transform things in macro arguments #define EXTERNAL(x) (x) + 5 i = EXTERNAL(static_cast<int>(absl::ToDoubleSeconds(d1))); // CHECK-MESSAGES: [[@LINE-1]]:16: warning: duration should be converted directly to an integer rather than through a type cast [abseil-duration-conversion-cast] - // CHECK-FIXES: EXTERNAL(absl::ToInt64Seconds(d1)); + // CHECK-FIXES: i = EXTERNAL(absl::ToInt64Seconds(d1)); #undef EXTERNAL // We don't want to transform this which get split across macro boundaries diff --git a/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-factory-float.cpp b/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-factory-float.cpp index 2f38dbf..9daaa72 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-factory-float.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-factory-float.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes %s abseil-duration-factory-float %t -- -- -I%S/Inputs +// RUN: %check_clang_tidy %s abseil-duration-factory-float %t -- -- -I%S/Inputs #include "absl/time/time.h" @@ -7,26 +7,26 @@ void ConvertFloatTest() { d = absl::Seconds(60.0); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: use the integer version of absl::Seconds [abseil-duration-factory-float] - // CHECK-FIXES: absl::Seconds(60); + // CHECK-FIXES: d = absl::Seconds(60); d = absl::Minutes(300.0); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: use the integer version of absl::Minutes [abseil-duration-factory-float] - // CHECK-FIXES: absl::Minutes(300); + // CHECK-FIXES: d = absl::Minutes(300); d = absl::Milliseconds(1e2); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: use the integer version of absl::Milliseconds [abseil-duration-factory-float] - // CHECK-FIXES: absl::Milliseconds(100); + // CHECK-FIXES: d = absl::Milliseconds(100); d = absl::Seconds(3.0f); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: use the integer version of absl::Seconds [abseil-duration-factory-float] - // CHECK-FIXES: absl::Seconds(3); + // CHECK-FIXES: d = absl::Seconds(3); d = absl::Seconds(3.); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: use the integer version of absl::Seconds [abseil-duration-factory-float] - // CHECK-FIXES: absl::Seconds(3); + // CHECK-FIXES: d = absl::Seconds(3); d = absl::Seconds(0x3.p0); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: use the integer version of absl::Seconds [abseil-duration-factory-float] - // CHECK-FIXES: absl::Seconds(3); + // CHECK-FIXES: d = absl::Seconds(3); d = absl::Seconds(0x3.p1); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: use the integer version of absl::Seconds [abseil-duration-factory-float] - // CHECK-FIXES: absl::Seconds(6); + // CHECK-FIXES: d = absl::Seconds(6); // Ignored expressions @@ -65,7 +65,7 @@ void InTemplate() { d = absl::Minutes(1.0); // 2 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: use the integer version of absl::Minutes [abseil-duration-factory-float] - // CHECK-FIXES: absl::Minutes(1); // 2 + // CHECK-FIXES: d = absl::Minutes(1); // 2 } void Instantiate() { @@ -78,27 +78,27 @@ void ConvertCastTest() { d = absl::Seconds(static_cast<double>(5)); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: use the integer version of absl::Seconds [abseil-duration-factory-float] - // CHECK-FIXES: absl::Seconds(5); + // CHECK-FIXES: d = absl::Seconds(5); d = absl::Minutes(static_cast<float>(5)); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: use the integer version of absl::Minutes [abseil-duration-factory-float] - // CHECK-FIXES: absl::Minutes(5); + // CHECK-FIXES: d = absl::Minutes(5); d = absl::Seconds((double) 5); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: use the integer version of absl::Seconds [abseil-duration-factory-float] - // CHECK-FIXES: absl::Seconds(5); + // CHECK-FIXES: d = absl::Seconds(5); d = absl::Minutes((float) 5); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: use the integer version of absl::Minutes [abseil-duration-factory-float] - // CHECK-FIXES: absl::Minutes(5); + // CHECK-FIXES: d = absl::Minutes(5); d = absl::Seconds(double(5)); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: use the integer version of absl::Seconds [abseil-duration-factory-float] - // CHECK-FIXES: absl::Seconds(5); + // CHECK-FIXES: d = absl::Seconds(5); d = absl::Minutes(float(5)); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: use the integer version of absl::Minutes [abseil-duration-factory-float] - // CHECK-FIXES: absl::Minutes(5); + // CHECK-FIXES: d = absl::Minutes(5); // This should not be flagged d = absl::Seconds(static_cast<int>(5.0)); diff --git a/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-factory-scale.cpp b/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-factory-scale.cpp index dd5f808..7213f5c 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-factory-scale.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-factory-scale.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes %s abseil-duration-factory-scale %t -- -- -I%S/Inputs +// RUN: %check_clang_tidy %s abseil-duration-factory-scale %t -- -- -I%S/Inputs #include "absl/time/time.h" @@ -11,87 +11,87 @@ void ScaleTest() { // Zeroes d = absl::Hours(0); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale] - // CHECK-FIXES: absl::ZeroDuration(); + // CHECK-FIXES: d = absl::ZeroDuration(); d = absl::Minutes(0); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale] - // CHECK-FIXES: absl::ZeroDuration(); + // CHECK-FIXES: d = absl::ZeroDuration(); d = absl::Seconds(0); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale] - // CHECK-FIXES: absl::ZeroDuration(); + // CHECK-FIXES: d = absl::ZeroDuration(); d = absl::Milliseconds(0); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale] - // CHECK-FIXES: absl::ZeroDuration(); + // CHECK-FIXES: d = absl::ZeroDuration(); d = absl::Microseconds(0); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale] - // CHECK-FIXES: absl::ZeroDuration(); + // CHECK-FIXES: d = absl::ZeroDuration(); d = absl::Nanoseconds(0); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale] - // CHECK-FIXES: absl::ZeroDuration(); + // CHECK-FIXES: d = absl::ZeroDuration(); d = absl::Seconds(0.0); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale] - // CHECK-FIXES: absl::ZeroDuration(); + // CHECK-FIXES: d = absl::ZeroDuration(); d = absl::Seconds(0x0.000001p-126f); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale] - // CHECK-FIXES: absl::ZeroDuration(); + // CHECK-FIXES: d = absl::ZeroDuration(); d = absl::Seconds(int{0}); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale] - // CHECK-FIXES: absl::ZeroDuration(); + // CHECK-FIXES: d = absl::ZeroDuration(); d = absl::Seconds(int64_t{0}); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale] - // CHECK-FIXES: absl::ZeroDuration(); + // CHECK-FIXES: d = absl::ZeroDuration(); d = absl::Seconds(float{0}); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use ZeroDuration() for zero-length time intervals [abseil-duration-factory-scale] - // CHECK-FIXES: absl::ZeroDuration(); + // CHECK-FIXES: d = absl::ZeroDuration(); // Fold seconds into minutes d = absl::Seconds(30 * 60); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale] - // CHECK-FIXES: absl::Minutes(30); + // CHECK-FIXES: d = absl::Minutes(30); d = absl::Seconds(60 * 30); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale] - // CHECK-FIXES: absl::Minutes(30); + // CHECK-FIXES: d = absl::Minutes(30); // Try a few more exotic multiplications d = absl::Seconds(60 * 30 * 60); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale] - // CHECK-FIXES: absl::Minutes(60 * 30); + // CHECK-FIXES: d = absl::Minutes(60 * 30); d = absl::Seconds(1e-3 * 30); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale] - // CHECK-FIXES: absl::Milliseconds(30); + // CHECK-FIXES: d = absl::Milliseconds(30); d = absl::Milliseconds(30 * 1000); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale] - // CHECK-FIXES: absl::Seconds(30); + // CHECK-FIXES: d = absl::Seconds(30); d = absl::Milliseconds(30 * 0.001); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale] - // CHECK-FIXES: absl::Microseconds(30); + // CHECK-FIXES: d = absl::Microseconds(30); // Multiple steps d = absl::Seconds(5 * 3600); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale] - // CHECK-FIXES: absl::Hours(5); + // CHECK-FIXES: d = absl::Hours(5); d = absl::Microseconds(5 * 1e6); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale] - // CHECK-FIXES: absl::Seconds(5); + // CHECK-FIXES: d = absl::Seconds(5); d = absl::Seconds(5 * 1e-6); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale] - // CHECK-FIXES: absl::Microseconds(5); + // CHECK-FIXES: d = absl::Microseconds(5); d = absl::Microseconds(5 * 1000000); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale] - // CHECK-FIXES: absl::Seconds(5); + // CHECK-FIXES: d = absl::Seconds(5); // Division d = absl::Hours(30 / 60.); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale] - // CHECK-FIXES: absl::Minutes(30); + // CHECK-FIXES: d = absl::Minutes(30); d = absl::Seconds(30 / 1000.); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale] - // CHECK-FIXES: absl::Milliseconds(30); + // CHECK-FIXES: d = absl::Milliseconds(30); d = absl::Milliseconds(30 / 1e3); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale] - // CHECK-FIXES: absl::Microseconds(30); + // CHECK-FIXES: d = absl::Microseconds(30); d = absl::Seconds(30 / 1e6); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: internal duration scaling can be removed [abseil-duration-factory-scale] - // CHECK-FIXES: absl::Microseconds(30); + // CHECK-FIXES: d = absl::Microseconds(30); // None of these should trigger the check d = absl::Seconds(60); diff --git a/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-subtraction.cpp b/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-subtraction.cpp index 167258e3..53b558b 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-subtraction.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-subtraction.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes %s abseil-duration-subtraction %t -- -- -I %S/Inputs +// RUN: %check_clang_tidy %s abseil-duration-subtraction %t -- -- -I %S/Inputs #include "absl/time/time.h" @@ -8,34 +8,34 @@ void f() { x = absl::ToDoubleSeconds(d) - 1.0; // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the duration domain [abseil-duration-subtraction] - // CHECK-FIXES: absl::ToDoubleSeconds(d - absl::Seconds(1)) + // CHECK-FIXES: x = absl::ToDoubleSeconds(d - absl::Seconds(1)); x = absl::ToDoubleSeconds(d) - absl::ToDoubleSeconds(d1); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the duration domain [abseil-duration-subtraction] - // CHECK-FIXES: absl::ToDoubleSeconds(d - d1); + // CHECK-FIXES: x = absl::ToDoubleSeconds(d - d1); x = absl::ToDoubleSeconds(d) - 6.5 - 8.0; // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the duration domain [abseil-duration-subtraction] - // CHECK-FIXES: absl::ToDoubleSeconds(d - absl::Seconds(6.5)) - 8.0; + // CHECK-FIXES: x = absl::ToDoubleSeconds(d - absl::Seconds(6.5)) - 8.0; x = absl::ToDoubleHours(d) - 1.0; // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the duration domain [abseil-duration-subtraction] - // CHECK-FIXES: absl::ToDoubleHours(d - absl::Hours(1)) + // CHECK-FIXES: x = absl::ToDoubleHours(d - absl::Hours(1)); x = absl::ToDoubleMinutes(d) - 1; // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the duration domain [abseil-duration-subtraction] - // CHECK-FIXES: absl::ToDoubleMinutes(d - absl::Minutes(1)) + // CHECK-FIXES: x = absl::ToDoubleMinutes(d - absl::Minutes(1)); x = absl::ToDoubleMilliseconds(d) - 9; // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the duration domain [abseil-duration-subtraction] - // CHECK-FIXES: absl::ToDoubleMilliseconds(d - absl::Milliseconds(9)) + // CHECK-FIXES: x = absl::ToDoubleMilliseconds(d - absl::Milliseconds(9)); x = absl::ToDoubleMicroseconds(d) - 9; // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the duration domain [abseil-duration-subtraction] - // CHECK-FIXES: absl::ToDoubleMicroseconds(d - absl::Microseconds(9)) + // CHECK-FIXES: x = absl::ToDoubleMicroseconds(d - absl::Microseconds(9)); x = absl::ToDoubleNanoseconds(d) - 42; // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the duration domain [abseil-duration-subtraction] - // CHECK-FIXES: absl::ToDoubleNanoseconds(d - absl::Nanoseconds(42)) + // CHECK-FIXES: x = absl::ToDoubleNanoseconds(d - absl::Nanoseconds(42)); // We can rewrite the argument of the duration conversion #define THIRTY absl::Seconds(30) x = absl::ToDoubleSeconds(THIRTY) - 1.0; // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the duration domain [abseil-duration-subtraction] - // CHECK-FIXES: absl::ToDoubleSeconds(THIRTY - absl::Seconds(1)) + // CHECK-FIXES: x = absl::ToDoubleSeconds(THIRTY - absl::Seconds(1)); #undef THIRTY // Some other contexts @@ -46,10 +46,10 @@ void f() { // A nested occurrence x = absl::ToDoubleSeconds(d) - absl::ToDoubleSeconds(absl::Seconds(5)); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the duration domain [abseil-duration-subtraction] - // CHECK-FIXES: absl::ToDoubleSeconds(d - absl::Seconds(5)) + // CHECK-FIXES: x = absl::ToDoubleSeconds(d - absl::Seconds(5)); x = absl::ToDoubleSeconds(d) - absl::ToDoubleSeconds(absl::Seconds(absl::ToDoubleSeconds(d1))); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the duration domain [abseil-duration-subtraction] - // CHECK-FIXES: absl::ToDoubleSeconds(d - absl::Seconds(absl::ToDoubleSeconds(d1))) + // CHECK-FIXES: x = absl::ToDoubleSeconds(d - absl::Seconds(absl::ToDoubleSeconds(d1))); // These should not match x = 5 - 6; diff --git a/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-unnecessary-conversion.cpp b/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-unnecessary-conversion.cpp index f4c69c5..92891b6 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-unnecessary-conversion.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/abseil/duration-unnecessary-conversion.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes -std=c++11-or-later %s abseil-duration-unnecessary-conversion %t -- -- -I %S/Inputs +// RUN: %check_clang_tidy -std=c++11-or-later %s abseil-duration-unnecessary-conversion %t -- -- -I %S/Inputs #include "absl/time/time.h" @@ -8,86 +8,86 @@ void f() { // Floating point d2 = absl::Hours(absl::ToDoubleHours(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Minutes(absl::ToDoubleMinutes(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Seconds(absl::ToDoubleSeconds(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Milliseconds(absl::ToDoubleMilliseconds(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Microseconds(absl::ToDoubleMicroseconds(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Nanoseconds(absl::ToDoubleNanoseconds(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; // Integer point d2 = absl::Hours(absl::ToInt64Hours(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Minutes(absl::ToInt64Minutes(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Seconds(absl::ToInt64Seconds(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Milliseconds(absl::ToInt64Milliseconds(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Microseconds(absl::ToInt64Microseconds(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Nanoseconds(absl::ToInt64Nanoseconds(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Hours(d1 / absl::Hours(1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Minutes(d1 / absl::Minutes(1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Seconds(d1 / absl::Seconds(1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Milliseconds(d1 / absl::Milliseconds(1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Microseconds(d1 / absl::Microseconds(1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Nanoseconds(d1 / absl::Nanoseconds(1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Hours(absl::FDivDuration(d1, absl::Hours(1))); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Minutes(absl::FDivDuration(d1, absl::Minutes(1))); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Seconds(absl::FDivDuration(d1, absl::Seconds(1))); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Milliseconds(absl::FDivDuration(d1, absl::Milliseconds(1))); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Microseconds(absl::FDivDuration(d1, absl::Microseconds(1))); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; d2 = absl::Nanoseconds(absl::FDivDuration(d1, absl::Nanoseconds(1))); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 + // CHECK-FIXES: d2 = d1; // As macro argument #define PLUS_FIVE_S(x) x + absl::Seconds(5) d2 = PLUS_FIVE_S(absl::Seconds(absl::ToInt64Seconds(d1))); // CHECK-MESSAGES: [[@LINE-1]]:20: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: PLUS_FIVE_S(d1) + // CHECK-FIXES: d2 = PLUS_FIVE_S(d1); #undef PLUS_FIVE_S // Split by macro: should not change @@ -103,40 +103,40 @@ void f() { // Multiplication d2 = absl::Nanoseconds(absl::ToDoubleNanoseconds(d1) * 2); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 * 2 + // CHECK-FIXES: d2 = d1 * 2; d2 = absl::Microseconds(absl::ToInt64Microseconds(d1) * 2); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 * 2 + // CHECK-FIXES: d2 = d1 * 2; d2 = absl::Milliseconds(absl::ToDoubleMilliseconds(d1) * 2); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 * 2 + // CHECK-FIXES: d2 = d1 * 2; d2 = absl::Seconds(absl::ToInt64Seconds(d1) * 2); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 * 2 + // CHECK-FIXES: d2 = d1 * 2; d2 = absl::Minutes(absl::ToDoubleMinutes(d1) * 2); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 * 2 + // CHECK-FIXES: d2 = d1 * 2; d2 = absl::Hours(absl::ToInt64Hours(d1) * 2); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = d1 * 2 + // CHECK-FIXES: d2 = d1 * 2; d2 = absl::Nanoseconds(2 * absl::ToDoubleNanoseconds(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = 2 * d1 + // CHECK-FIXES: d2 = 2 * d1; d2 = absl::Microseconds(2 * absl::ToInt64Microseconds(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = 2 * d1 + // CHECK-FIXES: d2 = 2 * d1; d2 = absl::Milliseconds(2 * absl::ToDoubleMilliseconds(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = 2 * d1 + // CHECK-FIXES: d2 = 2 * d1; d2 = absl::Seconds(2 * absl::ToInt64Seconds(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = 2 * d1 + // CHECK-FIXES: d2 = 2 * d1; d2 = absl::Minutes(2 * absl::ToDoubleMinutes(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = 2 * d1 + // CHECK-FIXES: d2 = 2 * d1; d2 = absl::Hours(2 * absl::ToInt64Hours(d1)); // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion] - // CHECK-FIXES: d2 = 2 * d1 + // CHECK-FIXES: d2 = 2 * d1; // These should not match d2 = absl::Seconds(absl::ToDoubleMilliseconds(d1)); diff --git a/clang-tools-extra/test/clang-tidy/checkers/abseil/redundant-strcat-calls.cpp b/clang-tools-extra/test/clang-tidy/checkers/abseil/redundant-strcat-calls.cpp index b5e866c..8fa1b1e 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/abseil/redundant-strcat-calls.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/abseil/redundant-strcat-calls.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes %s abseil-redundant-strcat-calls %t -- -- -isystem %clang_tidy_headers +// RUN: %check_clang_tidy %s abseil-redundant-strcat-calls %t -- -- -isystem %clang_tidy_headers #include <string> namespace absl { @@ -69,7 +69,7 @@ using absl::StrCat; void Positives() { std::string S = StrCat(1, StrCat("A", StrCat(1.1))); // CHECK-MESSAGES: [[@LINE-1]]:19: warning: multiple calls to 'absl::StrCat' can be flattened into a single call - // CHECK-FIXES: string S = StrCat(1, "A", 1.1); + // CHECK-FIXES: std::string S = StrCat(1, "A", 1.1); S = StrCat(StrCat(StrCat(StrCat(StrCat(1))))); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: multiple calls to 'absl::StrCat' can be flattened into a single call diff --git a/clang-tools-extra/test/clang-tidy/checkers/abseil/time-comparison.cpp b/clang-tools-extra/test/clang-tidy/checkers/abseil/time-comparison.cpp index 4de43ec..ad3ce4c 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/abseil/time-comparison.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/abseil/time-comparison.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes %s abseil-time-comparison %t -- -- -I%S/Inputs +// RUN: %check_clang_tidy %s abseil-time-comparison %t -- -- -I%S/Inputs #include "absl/time/time.h" @@ -11,67 +11,67 @@ void f() { // Check against the RHS b = x > absl::ToUnixSeconds(t1); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: absl::FromUnixSeconds(x) > t1; + // CHECK-FIXES: b = absl::FromUnixSeconds(x) > t1; b = x >= absl::ToUnixSeconds(t1); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: absl::FromUnixSeconds(x) >= t1; + // CHECK-FIXES: b = absl::FromUnixSeconds(x) >= t1; b = x == absl::ToUnixSeconds(t1); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: absl::FromUnixSeconds(x) == t1; + // CHECK-FIXES: b = absl::FromUnixSeconds(x) == t1; b = x <= absl::ToUnixSeconds(t1); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: absl::FromUnixSeconds(x) <= t1; + // CHECK-FIXES: b = absl::FromUnixSeconds(x) <= t1; b = x < absl::ToUnixSeconds(t1); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: absl::FromUnixSeconds(x) < t1; + // CHECK-FIXES: b = absl::FromUnixSeconds(x) < t1; b = x == absl::ToUnixSeconds(t1 - d2); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: absl::FromUnixSeconds(x) == t1 - d2; + // CHECK-FIXES: b = absl::FromUnixSeconds(x) == t1 - d2; b = absl::ToUnixSeconds(t1) > absl::ToUnixSeconds(t2); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: t1 > t2; + // CHECK-FIXES: b = t1 > t2; // Check against the LHS b = absl::ToUnixSeconds(t1) < x; // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: t1 < absl::FromUnixSeconds(x); + // CHECK-FIXES: b = t1 < absl::FromUnixSeconds(x); b = absl::ToUnixSeconds(t1) <= x; // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: t1 <= absl::FromUnixSeconds(x); + // CHECK-FIXES: b = t1 <= absl::FromUnixSeconds(x); b = absl::ToUnixSeconds(t1) == x; // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: t1 == absl::FromUnixSeconds(x); + // CHECK-FIXES: b = t1 == absl::FromUnixSeconds(x); b = absl::ToUnixSeconds(t1) >= x; // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: t1 >= absl::FromUnixSeconds(x); + // CHECK-FIXES: b = t1 >= absl::FromUnixSeconds(x); b = absl::ToUnixSeconds(t1) > x; // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: t1 > absl::FromUnixSeconds(x); + // CHECK-FIXES: b = t1 > absl::FromUnixSeconds(x); // Comparison against zero b = absl::ToUnixSeconds(t1) < 0.0; // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: t1 < absl::UnixEpoch(); + // CHECK-FIXES: b = t1 < absl::UnixEpoch(); b = absl::ToUnixSeconds(t1) < 0; // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: t1 < absl::UnixEpoch(); + // CHECK-FIXES: b = t1 < absl::UnixEpoch(); // Scales other than Seconds b = x > absl::ToUnixMicros(t1); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: absl::FromUnixMicros(x) > t1; + // CHECK-FIXES: b = absl::FromUnixMicros(x) > t1; b = x >= absl::ToUnixMillis(t1); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: absl::FromUnixMillis(x) >= t1; + // CHECK-FIXES: b = absl::FromUnixMillis(x) >= t1; b = x == absl::ToUnixNanos(t1); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: absl::FromUnixNanos(x) == t1; + // CHECK-FIXES: b = absl::FromUnixNanos(x) == t1; b = x <= absl::ToUnixMinutes(t1); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: absl::FromUnixMinutes(x) <= t1; + // CHECK-FIXES: b = absl::FromUnixMinutes(x) <= t1; b = x < absl::ToUnixHours(t1); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: absl::FromUnixHours(x) < t1; + // CHECK-FIXES: b = absl::FromUnixHours(x) < t1; // A long expression bool some_condition; @@ -88,20 +88,20 @@ void f() { int y; b = (y + 5) * 10 > absl::ToUnixMillis(t1); // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: absl::FromUnixMillis((y + 5) * 10) > t1; + // CHECK-FIXES: b = absl::FromUnixMillis((y + 5) * 10) > t1; // 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::ToUnixSeconds(t1)); // CHECK-MESSAGES: [[@LINE-1]]:23: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: VALUE_IF(1, absl::FromUnixSeconds(5) > t1); + // CHECK-FIXES: int a = VALUE_IF(1, absl::FromUnixSeconds(5) > t1); #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::ToUnixSeconds(t1)); // CHECK-MESSAGES: [[@LINE-1]]:24: warning: perform comparison in the time domain [abseil-time-comparison] - // CHECK-FIXES: VALUE_IF(1, absl::FromUnixSeconds(5) > t1); + // CHECK-FIXES: int a2 = VALUE_IF(1, absl::FromUnixSeconds(5) > t1); #undef VALUE_IF #undef VALUE_IF_2 diff --git a/clang-tools-extra/test/clang-tidy/checkers/abseil/time-subtraction.cpp b/clang-tools-extra/test/clang-tidy/checkers/abseil/time-subtraction.cpp index 82014e8f4..dde0681 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/abseil/time-subtraction.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/abseil/time-subtraction.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes -std=c++11-or-later %s abseil-time-subtraction %t -- -- -I %S/Inputs +// RUN: %check_clang_tidy -std=c++11-or-later %s abseil-time-subtraction %t -- -- -I %S/Inputs #include "absl/time/time.h" @@ -89,7 +89,7 @@ void f() { #define SECONDS(z) absl::Seconds(z) d = SECONDS(x - absl::ToUnixSeconds(t)); // CHECK-MESSAGES: [[@LINE-1]]:15: warning: perform subtraction in the time domain [abseil-time-subtraction] - // CHECK-FIXES: SECONDS(absl::ToInt64Seconds(absl::FromUnixSeconds(x) - t)) + // CHECK-FIXES: d = SECONDS(absl::ToInt64Seconds(absl::FromUnixSeconds(x) - t)); #undef SECONDS } diff --git a/clang-tools-extra/test/clang-tidy/checkers/abseil/upgrade-duration-conversions.cpp b/clang-tools-extra/test/clang-tidy/checkers/abseil/upgrade-duration-conversions.cpp index b5dfb4f..67fbe3f 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/abseil/upgrade-duration-conversions.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/abseil/upgrade-duration-conversions.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy --match-partial-fixes -std=c++11-or-later %s abseil-upgrade-duration-conversions %t -- -- -I%S/Inputs +// RUN: %check_clang_tidy -std=c++11-or-later %s abseil-upgrade-duration-conversions %t -- -- -I%S/Inputs using int64_t = long long; @@ -49,22 +49,22 @@ void arithmeticOperatorBasicPositive() { ConvertibleTo<int64_t> c; d *= (c + c) * c + c; // CHECK-MESSAGES: [[@LINE-1]]:8: warning: implicit conversion to 'int64_t' is deprecated in this context; use an explicit cast instead - // CHECK-FIXES: d *= static_cast<int64_t>((c + c) * c + c) + // CHECK-FIXES: d *= static_cast<int64_t>((c + c) * c + c); d /= (c + c) * c + c; // CHECK-MESSAGES: [[@LINE-1]]:8: warning: implicit conversion to 'int64_t' is deprecated in this context; use an explicit cast instead - // CHECK-FIXES: d /= static_cast<int64_t>((c + c) * c + c) + // CHECK-FIXES: d /= static_cast<int64_t>((c + c) * c + c); d = d * c * c; // CHECK-MESSAGES: [[@LINE-1]]:11: warning: implicit conversion to 'int64_t' is deprecated in this context; use an explicit cast instead // CHECK-MESSAGES: [[@LINE-2]]:15: warning: implicit conversion to 'int64_t' is deprecated in this context; use an explicit cast instead - // CHECK-FIXES: d = d * static_cast<int64_t>(c) * static_cast<int64_t>(c) + // CHECK-FIXES: d = d * static_cast<int64_t>(c) * static_cast<int64_t>(c); d = c * d * c; // CHECK-MESSAGES: [[@LINE-1]]:7: warning: implicit conversion to 'int64_t' is deprecated in this context; use an explicit cast instead // CHECK-MESSAGES: [[@LINE-2]]:15: warning: implicit conversion to 'int64_t' is deprecated in this context; use an explicit cast instead - // CHECK-FIXES: d = static_cast<int64_t>(c) * d * static_cast<int64_t>(c) + // CHECK-FIXES: d = static_cast<int64_t>(c) * d * static_cast<int64_t>(c); d = d / c * c; // CHECK-MESSAGES: [[@LINE-1]]:11: warning: implicit conversion to 'int64_t' is deprecated in this context; use an explicit cast instead // CHECK-MESSAGES: [[@LINE-2]]:15: warning: implicit conversion to 'int64_t' is deprecated in this context; use an explicit cast instead - // CHECK-FIXES: d = d / static_cast<int64_t>(c) * static_cast<int64_t>(c) + // CHECK-FIXES: d = d / static_cast<int64_t>(c) * static_cast<int64_t>(c); } void arithmeticOperatorBasicNegative() { @@ -407,7 +407,7 @@ template <typename T> void factoryTemplateAndMacro() { // CHECK-MESSAGES: [[@LINE-1]]:27: warning: implicit conversion to 'int64_t' is deprecated in this context; use an explicit cast instead (void)absl::Nanoseconds(CONVERTIBLE_TMP); // CHECK-MESSAGES: [[@LINE-1]]:27: warning: implicit conversion to 'int64_t' is deprecated in this context; use an explicit cast instead - // CHECK-FIXES: (void)absl::Nanoseconds(static_cast<int64_t>(CONVERTIBLE_TMP)) + // CHECK-FIXES: (void)absl::Nanoseconds(static_cast<int64_t>(CONVERTIBLE_TMP)); T_CALL_FACTORTY_INSIDE_MACRO; // CHECK-MESSAGES: [[@LINE-1]]:3: warning: implicit conversion to 'int64_t' is deprecated in this context; use an explicit cast instead } @@ -424,7 +424,7 @@ void factoryInMacros() { // CHECK-FIXES: (void)absl::Nanoseconds(static_cast<int64_t>(FUNCTION_MACRO(ConvertibleTo<int>()))); (void)absl::Nanoseconds(CONVERTIBLE_TMP); // CHECK-MESSAGES: [[@LINE-1]]:27: warning: implicit conversion to 'int64_t' is deprecated in this context; use an explicit cast instead - // CHECK-FIXES: (void)absl::Nanoseconds(static_cast<int64_t>(CONVERTIBLE_TMP)) + // CHECK-FIXES: (void)absl::Nanoseconds(static_cast<int64_t>(CONVERTIBLE_TMP)); ONLY_WARN_INSIDE_MACRO_FACTORY; // CHECK-MESSAGES: [[@LINE-1]]:3: warning: implicit conversion to 'int64_t' is deprecated in this context; use an explicit cast instead factoryTemplateAndMacro<ConvertibleTo<int>>(); |