[PATCH] D52360: [clang-tidy] Fix for performance-unnecessary-value-param, performance-unnecessary-copy-initialization and performance-for-range-copy
Felix Berger via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 26 07:10:30 PDT 2018
flx added a comment.
In https://reviews.llvm.org/D52360#1246472, @baloghadamsoftware wrote:
> In https://reviews.llvm.org/D52360#1246443, @danilaml wrote:
>
> > Would that also skip checks for something like `shared_ptr`?
>
>
> Yes, everything ending on `pointer`, `ptr`, `reference` or `ref`, first letter case insensitive.
std::shared_ptr should not be blacklisted. It is not free to copy it: It incurs two atomic operations and two branches.
Users should blacklist it if they know they don't care about this or not use the check.
While it looks weird for the check to suggest to pass std::shared_ptr by reference it is correct. A better change would be to just pass the raw pointer in this case:
std::shared_ptr<Ptr> p;
PassByRawPointer(p.get());
But this would require function signature change that breaks callers outside of the translation unit.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D52360
More information about the cfe-commits
mailing list