[PATCH] D55044: [clang-tidy] check for Abseil make_unique

Jonas Toth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 2 03:59:36 PST 2018


JonasToth added a comment.

In D55044#1312438 <https://reviews.llvm.org/D55044#1312438>, @lebedev.ri wrote:

> Thanks for working on this.
>  Semi-duplicate of D50852 <https://reviews.llvm.org/D50852> Please see discussion there.
>  It should not be an abseil-specific check, the prefix (`std`,`abseil`), and the function (`make_unique`) should be a config option, and it should likely be a part of `modernize-use-auto`.


I agree here. Instead of reimplementing the functionality we should rather refactor the existing check and make it flexible. It is possible to register the `absl` version of it with a different default-configuration so the refactoring will be the correct one.



================
Comment at: test/clang-tidy/abseil-make-unique.cpp:43
+
+  std::unique_ptr<int> b;
+  b.reset(new int(2));
----------------
All your test cases seem to create only a single `unique_ptr`, please add cases like

```
std::unique_ptr<int> b1(new int(32)), b2(new int(42));
```
>From my experience in rewriting decls, they should be excluded. It is very cumbersome to get it right in all cases (think pointers, pointer to pointers, const, ...) and `readability-isolcate-declaration` exists to split variable declarations first.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55044/new/

https://reviews.llvm.org/D55044





More information about the cfe-commits mailing list