[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision. aaron.ballman added a comment. I've commit in r347163. Thank you for the patch! https://reviews.llvm.org/D54246 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinf

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In https://reviews.llvm.org/D54246#1301940, @hwright wrote: > @aaron.ballman I don't actually have the commit bit, can you commit this, or > are we waiting for further review? No further review required. I'm happy to commit for you. I'll do it later today or tom

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-16 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added a comment. @aaron.ballman I don't actually have the commit bit, can you commit this, or are we waiting for further review? https://reviews.llvm.org/D54246 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/c

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. LGTM! Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:73 + case DurationScale::Hours: +if (Multiplier <= 1.0 / 60.0) + return std::make_tu

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-16 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added a comment. I think this is ready to go, please advise on next steps. https://reviews.llvm.org/D54246 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-16 Thread Hyrum Wright via Phabricator via cfe-commits
hwright marked 5 inline comments as done. hwright added inline comments. Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:73 + case DurationScale::Hours: +if (Multiplier <= 1.0 / 60.0) + return std::make_tuple(DurationScale::Minutes, Multiplier * 60.0); -

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:63 + assert(FloatLit != nullptr && "Neither IntLit nor FloatLit set"); + return FloatLit->getValueAsApproximateDouble(); +} hwright wrote: > aaron.ballman wrote: >

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-14 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added inline comments. Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:57-58 +// One and only one of `IntLit` and `FloatLit` should be provided. +static double GetValue(const IntegerLiteral *IntLit, + const FloatingLiteral *FloatLit) { +

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-14 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 174039. hwright marked 11 inline comments as done. hwright added a comment. Combined multiplication and division logic, and also now handles scaling of multiple steps (e.g., Seconds * 3600). https://reviews.llvm.org/D54246 Files: clang-tidy/abseil/Abseil

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:57-58 +// One and only one of `IntLit` and `FloatLit` should be provided. +static double GetValue(const IntegerLiteral *IntLit, + const FloatingLiteral *FloatLit

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-12 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added inline comments. Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:57-58 +// One and only one of `IntLit` and `FloatLit` should be provided. +static double GetValue(const IntegerLiteral *IntLit, + const FloatingLiteral *FloatLit) { +

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-12 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 173714. hwright marked 11 inline comments as done. hwright added a comment. Addressed small concerns. Larger issues pending feedback. https://reviews.llvm.org/D54246 Files: clang-tidy/abseil/AbseilTidyModule.cpp clang-tidy/abseil/CMakeLists.txt clang

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:39 +static llvm::Optional +GetScaleForFactory(llvm::StringRef FactoryName) { + static const std::unordered_map ScaleMap( GetScaleForFactory -> getScaleForFactory, pe

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-10 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 173543. hwright marked 16 inline comments as done. hwright added a comment. Addressed reviewer feedback. https://reviews.llvm.org/D54246 Files: clang-tidy/abseil/AbseilTidyModule.cpp clang-tidy/abseil/CMakeLists.txt clang-tidy/abseil/DurationFactorySc

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-10 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added inline comments. Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:74 + case DurationScale::Minutes: +if (Multiplier == 60.0) + return DurationScale::Hours; hokein wrote: > we are comparing with floats, I think we should use some

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:36 +GetScaleForFactory(llvm::StringRef FactoryName) { + static const auto *ScaleMap = + new std::unordered_map( hokein wrote: > aaron.ballman wrote: > > hwright

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments. Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:36 +GetScaleForFactory(llvm::StringRef FactoryName) { + static const auto *ScaleMap = + new std::unordered_map( aaron.ballman wrote: > hwright wrote: > > Eugene.Zelenk

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:36 +GetScaleForFactory(llvm::StringRef FactoryName) { + static const auto *ScaleMap = + new std::unordered_map( hwright wrote: > Eugene.Zelenko wrote: > > This

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-08 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments. Comment at: docs/ReleaseNotes.rst:88 + Checks for cases where arguments to ``absl::Duration`` factory functions are + scaled internally and could be changed to a different factory function. This + check also looks for arguements with a ze

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-08 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added inline comments. Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:36 +GetScaleForFactory(llvm::StringRef FactoryName) { + static const auto *ScaleMap = + new std::unordered_map( Eugene.Zelenko wrote: > This will cause memory leaks,

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-08 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 173166. hwright marked 4 inline comments as done. hwright added a comment. Address reviewer comments https://reviews.llvm.org/D54246 Files: clang-tidy/abseil/AbseilTidyModule.cpp clang-tidy/abseil/CMakeLists.txt clang-tidy/abseil/DurationFactoryScaleC

[PATCH] D54246: [clang-tidy] Add the abseil-duration-factory-scale check

2018-11-07 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments. Comment at: clang-tidy/abseil/DurationFactoryScaleCheck.cpp:36 +GetScaleForFactory(llvm::StringRef FactoryName) { + static const auto *ScaleMap = + new std::unordered_map( This will cause memory leaks, so may be unique_