diff options
author | Hyrum Wright <hwright@google.com> | 2018-12-21 21:07:11 +0000 |
---|---|---|
committer | Hyrum Wright <hwright@google.com> | 2018-12-21 21:07:11 +0000 |
commit | 1602d005eda0b54580f7d3dad5937e8e1ca79c47 (patch) | |
tree | 17cdcdedc90b9a2a53a9109e37c587c404fc8ab2 /clang-tools-extra/test | |
parent | 15fe95fd6add3ad80742f64ca90fbb35c1108694 (diff) |
[clang-tidy] Be more liberal about literal zeroes in abseil checks
Summary:
Previously, we'd only match on literal floating or integral zeroes, but I've now also learned that some users spell that value as int{0} or float{0}, which also need to be matched.
Differential Revision: https://reviews.llvm.org/D56012
Diffstat (limited to 'clang-tools-extra/test')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/abseil-duration-factory-scale.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/abseil-duration-factory-scale.cpp b/clang-tools-extra/test/clang-tidy/abseil-duration-factory-scale.cpp index dc94773f5ac..04c361328f5 100644 --- a/clang-tools-extra/test/clang-tidy/abseil-duration-factory-scale.cpp +++ b/clang-tools-extra/test/clang-tidy/abseil-duration-factory-scale.cpp @@ -2,6 +2,9 @@ #include "absl/time/time.h" +namespace std { typedef long long int64_t; } +using int64_t = std::int64_t; + void ScaleTest() { absl::Duration d; @@ -30,6 +33,15 @@ void ScaleTest() { 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(); + 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(); + 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(); + 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(); // Fold seconds into minutes d = absl::Seconds(30 * 60); @@ -83,6 +95,8 @@ void ScaleTest() { // None of these should trigger the check d = absl::Seconds(60); + d = absl::Seconds(int{60}); + d = absl::Seconds(float{60}); d = absl::Seconds(60 + 30); d = absl::Seconds(60 - 30); d = absl::Seconds(50 * 30); |