[PATCH] D50852: [clang-tidy] abseil-auto-make-unique
Jonas Toth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 17 00:26:31 PDT 2018
JonasToth added inline comments.
================
Comment at: test/clang-tidy/abseil-auto-make-unique.cpp:73
+ // Different type. No change.
+ std::unique_ptr<Base> z = make_unique<Derived>();
+ std::unique_ptr<Base> z2(make_unique<Derived>());
----------------
JonasToth wrote:
> lets consider a 3 level class hierarchy.
>
> ```
> struct A { virtual void Something(); };
> struct B : A { void Something() override; };
> struct C : B { void Something() override; };
>
> std::unique_ptr<B> b_ptr = make_unique<B>(), c_ptr = make_unique<C>();
> std::unique_ptr<B> c_ptr2 = make_unique<C>(), b_ptr2 = make_unique<B>();
> ```
>
> What is the behaviour? I expect that these places break when transformed. To avoid you can check the `VarDecl` `isSingleDecl()` (or similar, i forgot the exact name) and only emit a fixit if it is.
> Doing type transformations for the multi-definitions is tricky.
`isSingleDecl()` is a member of `DeclStmt`.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D50852
More information about the cfe-commits
mailing list