[PATCH] D55245: [clang-tidy] Add the abseil-duration-subtraction check
Roman Lebedev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 10 04:26:55 PST 2018
lebedev.ri added inline comments.
================
Comment at: clang-tidy/abseil/DurationRewriter.cpp:20-39
+struct DurationScale2IndexFunctor {
+ using argument_type = DurationScale;
+ unsigned operator()(DurationScale Scale) const {
+ switch (Scale) {
+ case DurationScale::Hours:
+ return 0;
+ case DurationScale::Minutes:
----------------
You should not need this if you change the `enum` instead.
================
Comment at: clang-tidy/abseil/DurationRewriter.cpp:66-77
+ InverseMap[DurationScale::Hours] =
+ std::make_pair("::absl::ToDoubleHours", "::absl::ToInt64Hours");
+ InverseMap[DurationScale::Minutes] =
+ std::make_pair("::absl::ToDoubleMinutes", "::absl::ToInt64Minutes");
+ InverseMap[DurationScale::Seconds] =
+ std::make_pair("::absl::ToDoubleSeconds", "::absl::ToInt64Seconds");
+ InverseMap[DurationScale::Milliseconds] = std::make_pair(
----------------
I was thinking of more like
```
for(std::pair<??, ??> e : std::initializer_list({
{DurationScale::Hours, std::make_pair("::absl::ToDoubleHours", "::absl::ToInt64Hours")}.
}))
InverseMap[e.first] = e.second;
```
================
Comment at: clang-tidy/abseil/DurationRewriter.h:22-23
/// Duration factory and conversion scales
enum class DurationScale : std::int8_t {
Hours,
Minutes,
----------------
```
enum class DurationScale : std::int8_t {
Hours = 0,
Minutes,
...
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55245/new/
https://reviews.llvm.org/D55245
More information about the cfe-commits
mailing list