1- // RUN: %check_clang_tidy --match-partial-fixes %s abseil-duration-addition %t -- -- -I%S/Inputs
1+ // RUN: %check_clang_tidy %s abseil-duration-addition %t -- -- -I%S/Inputs
22
33#include " absl/time/time.h"
44
@@ -8,68 +8,68 @@ void f() {
88
99 i = absl::ToUnixHours (t) + 5 ;
1010 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
11- // CHECK-FIXES: absl::ToUnixHours(t + absl::Hours(5))
11+ // CHECK-FIXES: i = absl::ToUnixHours(t + absl::Hours(5));
1212 i = absl::ToUnixMinutes (t) + 5 ;
1313 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
14- // CHECK-FIXES: absl::ToUnixMinutes(t + absl::Minutes(5))
14+ // CHECK-FIXES: i = absl::ToUnixMinutes(t + absl::Minutes(5));
1515 i = absl::ToUnixSeconds (t) + 5 ;
1616 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
17- // CHECK-FIXES: absl::ToUnixSeconds(t + absl::Seconds(5))
17+ // CHECK-FIXES: i = absl::ToUnixSeconds(t + absl::Seconds(5));
1818 i = absl::ToUnixMillis (t) + 5 ;
1919 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
20- // CHECK-FIXES: absl::ToUnixMillis(t + absl::Milliseconds(5))
20+ // CHECK-FIXES: i = absl::ToUnixMillis(t + absl::Milliseconds(5));
2121 i = absl::ToUnixMicros (t) + 5 ;
2222 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
23- // CHECK-FIXES: absl::ToUnixMicros(t + absl::Microseconds(5))
23+ // CHECK-FIXES: i = absl::ToUnixMicros(t + absl::Microseconds(5));
2424 i = absl::ToUnixNanos (t) + 5 ;
2525 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
26- // CHECK-FIXES: absl::ToUnixNanos(t + absl::Nanoseconds(5))
26+ // CHECK-FIXES: i = absl::ToUnixNanos(t + absl::Nanoseconds(5));
2727
2828 i = 3 + absl::ToUnixHours (t);
2929 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
30- // CHECK-FIXES: absl::ToUnixHours(absl::Hours(3) + t)
30+ // CHECK-FIXES: i = absl::ToUnixHours(absl::Hours(3) + t);
3131 i = 3 + absl::ToUnixMinutes (t);
3232 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
33- // CHECK-FIXES: absl::ToUnixMinutes(absl::Minutes(3) + t)
33+ // CHECK-FIXES: i = absl::ToUnixMinutes(absl::Minutes(3) + t);
3434 i = 3 + absl::ToUnixSeconds (t);
3535 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
36- // CHECK-FIXES: absl::ToUnixSeconds(absl::Seconds(3) + t)
36+ // CHECK-FIXES: i = absl::ToUnixSeconds(absl::Seconds(3) + t);
3737 i = 3 + absl::ToUnixMillis (t);
3838 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
39- // CHECK-FIXES: absl::ToUnixMillis(absl::Milliseconds(3) + t)
39+ // CHECK-FIXES: i = absl::ToUnixMillis(absl::Milliseconds(3) + t);
4040 i = 3 + absl::ToUnixMicros (t);
4141 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
42- // CHECK-FIXES: absl::ToUnixMicros(absl::Microseconds(3) + t)
42+ // CHECK-FIXES: i = absl::ToUnixMicros(absl::Microseconds(3) + t);
4343 i = 3 + absl::ToUnixNanos (t);
4444 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
45- // CHECK-FIXES: absl::ToUnixNanos(absl::Nanoseconds(3) + t)
45+ // CHECK-FIXES: i = absl::ToUnixNanos(absl::Nanoseconds(3) + t);
4646
4747 // Undoing inverse conversions
4848 i = absl::ToUnixMicros (t) + absl::ToInt64Microseconds (absl::Seconds (1 ));
4949 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
50- // CHECK-FIXES: absl::ToUnixMicros(t + absl::Seconds(1))
50+ // CHECK-FIXES: i = absl::ToUnixMicros(t + absl::Seconds(1));
5151
5252 // Parens
5353 i = 3 + (absl::ToUnixHours (t));
5454 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
55- // CHECK-FIXES: absl::ToUnixHours(absl::Hours(3) + t)
55+ // CHECK-FIXES: i = absl::ToUnixHours(absl::Hours(3) + t);
5656
5757 // Float folding
5858 i = absl::ToUnixSeconds (t) + 5.0 ;
5959 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
60- // CHECK-FIXES: absl::ToUnixSeconds(t + absl::Seconds(5))
60+ // CHECK-FIXES: i = absl::ToUnixSeconds(t + absl::Seconds(5));
6161
6262 // We can rewrite the argument of the duration conversion
6363#define THIRTY absl::FromUnixSeconds (30 )
6464 i = absl::ToUnixSeconds(THIRTY) + 1;
6565 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
66- // CHECK-FIXES: absl::ToUnixSeconds(THIRTY + absl::Seconds(1))
66+ // CHECK-FIXES: i = absl::ToUnixSeconds(THIRTY + absl::Seconds(1));
6767#undef THIRTY
6868
6969 // Some other contexts
7070 if (absl::ToUnixSeconds (t) + 1.0 > 10 ) {}
7171 // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform addition in the duration domain [abseil-duration-addition]
72- // CHECK-FIXES: absl::ToUnixSeconds(t + absl::Seconds(1))
72+ // CHECK-FIXES: if ( absl::ToUnixSeconds(t + absl::Seconds(1)) > 10) {}
7373
7474 // These should not match
7575 i = 5 + 6 ;
@@ -88,7 +88,7 @@ template<typename T>
8888void foo (absl::Time t) {
8989 int i = absl::ToUnixNanos (t) + T{};
9090 // CHECK-MESSAGES: [[@LINE-1]]:11: warning: perform addition in the duration domain [abseil-duration-addition]
91- // CHECK-FIXES: absl::ToUnixNanos(t + absl::Nanoseconds(T{}))
91+ // CHECK-FIXES: int i = absl::ToUnixNanos(t + absl::Nanoseconds(T{}));
9292}
9393
9494void g () {
0 commit comments