[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes
Gábor Horváth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 7 06:29:43 PST 2017
xazax.hun added a comment.
In https://reviews.llvm.org/D33722#916990, @aaron.ballman wrote:
> In https://reviews.llvm.org/D33722#916540, @xazax.hun wrote:
>
> > Also, bugprone might be a better module to put this?
>
>
> I don't have strong opinions on misc vs bugprone (they're both effectively catch-alls for tidy checks, as best I can tell).
@alexfh, do you have an opinion here?
================
Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:69
+ (Ctor->getAccess() == AS_private || Ctor->isDeleted())) {
+ NonCopyableBase = true;
+ break;
----------------
aaron.ballman wrote:
> What if the base class is inherited privately? e.g.,
> ```
> struct Base {
> Base(const Base&) {}
> };
>
> struct Derived : private Base {
> Derived(const Derived &) {}
> };
> ```
We warn in that case too. I added a test to demonstrate this. I think we still want to copy private bases in copy ctors if they are not empty and copyable.
https://reviews.llvm.org/D33722
More information about the cfe-commits
mailing list