[PATCH] D59183: [clang-tidy] Expand cases covered by the abseil-duration-unnecessary-conversion check

Hyrum Wright via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 13 11:10:00 PDT 2019


hwright added inline comments.


================
Comment at: test/clang-tidy/abseil-duration-unnecessary-conversion.cpp:48
 
+  d2 = absl::Hours(d1 / absl::Hours(1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove unnecessary absl::Duration conversions [abseil-duration-unnecessary-conversion]
----------------
hokein wrote:
> An off-topic comment: do we have this code pattern in the codebase? From my understanding, the usage like this is really rare. 
This mostly shows up in migrations.  When an existing API takes an integer, and caller already has a `Duration`, they sometimes use `dur / absl::Seconds(1)` to get back in integer at the callsite.   After a migration, we end up with `absl::Seconds(dur /absl::Seconds(1))`, which should really just be `dur`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59183/new/

https://reviews.llvm.org/D59183





More information about the cfe-commits mailing list