warns to use 'auto' to avoid repeating the type name and fixes the issue
Replace:
std::unique_ptr<Foo> x = make_unique<Foo>(...);
with:
auto x = make_unique<Foo>(...);
Differential D50852
[clang-tidy] abseil-auto-make-unique hugoeg on Aug 16 2018, 10:30 AM. Authored by
Details warns to use 'auto' to avoid repeating the type name and fixes the issue Replace: std::unique_ptr<Foo> x = make_unique<Foo>(...); with: auto x = make_unique<Foo>(...);
Diff Detail Event TimelineComment Actions
Comment Actions since this check checks for absl::make_unique primarily Comment Actions Why do you think it would be weird?
Just checking, was there some memo i missed that abseil-related checks are exempt from all the usual guidelines? Comment Actions I checked fast and modernize-use-auto does not catch this case.
Because this check is really not abseil-library-specific. I agree that this check is general for make_... templates. It should be either an addition to modernize-use-auto or readability- or so. What we do for such cases, where the check is generally useful and specific to a guideline at the same time is aliasing. You can take a look at hicpp- module where most checks are actually aliases.
Comment Actions First of all, thanks, Hugo, for your check! My +1 for extending modernize-use-auto as currently it doesn't support cases your check supports. std::unique_ptr< int >y = std::make_unique<int>(); with auto y = std::make_unique<int>(); is logically the same as replacing long long int *y = new long long int (42); with auto* y = new long long int (42); what modernize-use-auto does. So your check should extend the existing one and not create one more check IMHO.
Comment Actions Marking both of these as "changes requested" to highlight the similarity of issues in them. |
Please clang-format, return on next line.