[clang-tidy] Add the abseil-duration-factory-float check
authorJonas Toth <jonas.toth@gmail.com>
Wed, 24 Oct 2018 17:40:50 +0000 (17:40 +0000)
committerJonas Toth <jonas.toth@gmail.com>
Wed, 24 Oct 2018 17:40:50 +0000 (17:40 +0000)
commit618c0bc363033a2a9d4a3f2b1a0c09c4703e4e55
tree9b096c4851be3e4180e3ea8e6eb815d68bc25a0e
parentc342c8b87e8f8918060b364b7ba67dc72b2237a3
[clang-tidy] Add the abseil-duration-factory-float check

Summary:
This check finds cases where calls to an absl::Duration factory could use the more efficient integer overload.

For example:
// Original - Providing a floating-point literal.
absl::Duration d = absl::Seconds(10.0);

// Suggested - Use an integer instead.
absl::Duration d = absl::Seconds(10);

Patch by hwright.

Reviewers: alexfh, hokein, aaron.ballman, JonasToth

Reviewed By: hokein, JonasToth

Subscribers: zturner, xazax.hun, Eugene.Zelenko, mgorny, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D53339

llvm-svn: 345167
clang-tools-extra/clang-tidy/abseil/AbseilTidyModule.cpp
clang-tools-extra/clang-tidy/abseil/CMakeLists.txt
clang-tools-extra/clang-tidy/abseil/DurationFactoryFloatCheck.cpp [new file with mode: 0644]
clang-tools-extra/clang-tidy/abseil/DurationFactoryFloatCheck.h [new file with mode: 0644]
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/abseil-duration-factory-float.rst [new file with mode: 0644]
clang-tools-extra/docs/clang-tidy/checks/list.rst
clang-tools-extra/test/clang-tidy/abseil-duration-factory-float.cpp [new file with mode: 0644]