[clang-tools-extra] [clang-tidy][NFC] Migrate tests away from `--match-partial-fixes` (PR #162851)

via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 10 07:18:33 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-tidy

Author: Victor Chernyakin (localspook)

<details>
<summary>Changes</summary>

Follow up to #<!-- -->162293.

Now the question is: do we want to remove the `--match-partial-fixes` option entirely? It *could* break downstream users of `check_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.

---

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:

- (modified) clang-tools-extra/test/clang-tidy/checkers/abseil/duration-addition.cpp (+19-19) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/abseil/duration-comparison.cpp (+34-34) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/abseil/duration-conversion-cast.cpp (+20-20) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/abseil/duration-factory-float.cpp (+15-15) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/abseil/duration-factory-scale.cpp (+26-26) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/abseil/duration-subtraction.cpp (+12-12) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/abseil/duration-unnecessary-conversion.cpp (+38-38) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/abseil/redundant-strcat-calls.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/abseil/time-comparison.cpp (+23-23) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/abseil/time-subtraction.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/abseil/upgrade-duration-conversions.cpp (+8-8) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/altera/struct-pack-align.cpp (+8-10) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/android/cloexec-memfd-create.cpp (+5-5) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/android/cloexec-open.cpp (+19-19) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/android/cloexec-socket.cpp (+7-7) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/incorrect-enable-shared-from-this.cpp (+7-7) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/move-forwarding-reference.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-in-initialization-strlen.c (+4-4) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-memcpy-safe-cxx.cpp (+3-3) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-strlen.c (+4-4) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/not-null-terminated-result-wcslen.cpp (+5-5) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/posix-return.cpp (+16-16) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/stringview-nullptr.cpp (+53-27) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-string-compare.cpp (+38-38) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/bugprone/swapped-arguments.cpp (+3-3) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-constant-array-index.cpp (+1-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init-use-assignment.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-member-init.cpp (+3-3) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/virtual-class-destructor.cpp (+9-17) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/google/build-explicit-make-pair.cpp (+5-5) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/google/objc-avoid-nsobject-new.m (+4-4) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/google/upgrade-googletest-case.cpp (+7-5) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-isa-or-dyn-cast-in-conditionals.cpp (+3-3) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-register-over-unsigned.cpp (+40-40) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/llvm/twine-local.cpp (+8-8) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/llvm/use-new-mlir-op-builder.cpp (+8-9) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-pointers.cpp (+4-4) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-pointer-as-values.cpp (+8-9) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/misc/const-correctness-values.cpp (+66-66) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/misc/definitions-in-headers.hpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/misc/unused-parameters.cpp (+10-10) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/avoid-bind.cpp (+9-9) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/concat-nested-namespaces.cpp (+10-10) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/loop-convert-basic.cpp (+79-79) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/loop-convert-const.cpp (+39-39) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/loop-convert-extra.cpp (+95-94) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/make-shared.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/make-unique.cpp (+3-3) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/min-max-use-initializer-list.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/pass-by-value.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/redundant-void-arg.cpp (+5-5) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/replace-auto-ptr.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/use-auto-cast-remove-stars.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/use-auto-cast.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/use-auto-for-pointer.cpp (+8-8) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/use-auto-iterator.cpp (+4-4) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/use-auto-min-type-name-length.cpp (+8-8) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp (+3-3) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison-qt.cpp (+3-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp (+3-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/use-nullptr.cpp (+7-5) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/use-override.cpp (+5-3) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format.cpp (+15-15) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-print.cpp (+8-8) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/performance/noexcept-move-constructor-fix.cpp (+14-14) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp (+3-3) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param-delayed.cpp (+4-4) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param.cpp (+4-4) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/readability/braces-around-statements.cpp (+6-5) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/readability/container-size-empty.cpp (+3-3) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.c (+5-5) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp (+5-5) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/readability/math-missing-parentheses.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/readability/simplify-boolean-expr-members.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/readability/simplify-boolean-expr.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-custom-list.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/infrastructure/duplicate-conflicted-fixes-of-alias-checkers.cpp (+2-2) 
- (modified) clang-tools-extra/test/clang-tidy/infrastructure/duplicate-fixes-of-alias-checkers.cpp (+2-2) 


``````````diff
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]

``````````

</details>


https://github.com/llvm/llvm-project/pull/162851


More information about the cfe-commits mailing list