modernize-use-auto#8459
Conversation
fbusato
left a comment
There was a problem hiding this comment.
I'm generally in favor of that, but my feeling is that @gevtushenko and @miscco could have a different opinion
To perhaps allay some fears here,
Or specifically for standard library iterators: std::vector<int>::iterator it = v.begin();
// becomes
auto it = v.begin(); |
bernhardmgruber
left a comment
There was a problem hiding this comment.
This PR is like 95% fine and I prefer the refactoring. I looked through a third or so.
| DecomposerT decomposer = {}) | ||
| { | ||
| bit_ordered_type(&unsigned_keys)[ItemsPerThread] = reinterpret_cast<bit_ordered_type(&)[ItemsPerThread]>(keys); | ||
| auto(&unsigned_keys)[ItemsPerThread] = reinterpret_cast<bit_ordered_type(&)[ItemsPerThread]>(keys); |
There was a problem hiding this comment.
Remark: haven't seen a reinterpretation as a reference to an array in a long time
| auto max_num_blocks = ::cuda::ceil_div( | ||
| static_cast<int>(::cuda::std::min(num_items, static_cast<OffsetT>(PORTION_SIZE))), ONESWEEP_TILE_ITEMS); |
There was a problem hiding this comment.
This looks a bit like clang-tidy knows that PortionOffsetT is int. Can we reflect this in the cast?
| auto max_num_blocks = ::cuda::ceil_div( | |
| static_cast<int>(::cuda::std::min(num_items, static_cast<OffsetT>(PORTION_SIZE))), ONESWEEP_TILE_ITEMS); | |
| auto max_num_blocks = ::cuda::ceil_div( | |
| static_cast<PortionOffsetT>(::cuda::std::min(num_items, static_cast<OffsetT>(PORTION_SIZE))), ONESWEEP_TILE_ITEMS); |
There was a problem hiding this comment.
Hmmm I am confused, the int cast already existed before, you want to change that to PortionOffsetT as well?
3db78af to
c93fefb
Compare
😬 CI Workflow Results🟥 Finished in 3h 17m: Pass: 99%/379 | Total: 9d 08h | Max: 2h 07m | Hits: 89%/528882See results here. |
miscco
left a comment
There was a problem hiding this comment.
I am really not sure about this. Auto is often usefull if we have a static_cast on the other side of an assignment
But in many cases this creates visual noise, when we have multiple variables and one of them suddenly becomes auto
Often its also not easy to keep the type in min for more complex code, so I am not sure whether its a win
|
|
||
| const SampleT lower_level_r = 0; | ||
| const SampleT upper_level_r = get_upper_level<SampleT>(num_bins, elements); | ||
| const auto upper_level_r = get_upper_level<SampleT>(num_bins, elements); |
There was a problem hiding this comment.
I am against this one, it breaks alignnment
There was a problem hiding this comment.
What if I made them all auto? And
const SampleT lower_level_r = 0;
// to
const auto lower_level_r = SamepleT{0};I can silence them with // NOLINT but I'd rather avoid that if there are other code changes we can make to satisfy the linter.
There was a problem hiding this comment.
we could enforce variable alignment 😁 https://clang.llvm.org/docs/ClangFormatStyleOptions.html#alignconsecutivedeclarations
|
|
||
| const SampleT lower_level = 0; | ||
| const SampleT upper_level = get_upper_level<SampleT>(num_bins, elements); | ||
| const auto upper_level = get_upper_level<SampleT>(num_bins, elements); |
|
|
||
| cuda::std::bool_constant<sizeof(SampleT) == 1> is_byte_sample; | ||
| OffsetT num_row_pixels = static_cast<OffsetT>(elements); | ||
| auto num_row_pixels = static_cast<OffsetT>(elements); |
|
Since there seems to be no concerted votes for this feature, I will go ahead and close this PR and leave the check disabled. |
Description
closes
Checklist