forked from OSchip/llvm-project
[clang-tidy] cppcoreguidelines-pro-type-member-init: suppress warning for default member funcs
Modify the cppcoreguidelines-pro-type-member-init checker to ignore warnings from the move and copy-constructors when they are compiler defined with `= default` outside of the type declaration. Reported as [LLVM bug 36819](https://bugs.llvm.org/show_bug.cgi?id=36819) Reviewed By: malcolm.parsons Differential Revision: https://reviews.llvm.org/D93333
This commit is contained in:
parent
99562332e3
commit
35f2c3a8b4
|
@ -297,6 +297,10 @@ void ProTypeMemberInitCheck::check(const MatchFinder::MatchResult &Result) {
|
||||||
// Skip declarations delayed by late template parsing without a body.
|
// Skip declarations delayed by late template parsing without a body.
|
||||||
if (!Ctor->getBody())
|
if (!Ctor->getBody())
|
||||||
return;
|
return;
|
||||||
|
// Skip out-of-band explicitly defaulted special member functions
|
||||||
|
// (except the default constructor).
|
||||||
|
if (Ctor->isExplicitlyDefaulted() && !Ctor->isDefaultConstructor())
|
||||||
|
return;
|
||||||
checkMissingMemberInitializer(*Result.Context, *Ctor->getParent(), Ctor);
|
checkMissingMemberInitializer(*Result.Context, *Ctor->getParent(), Ctor);
|
||||||
checkMissingBaseClassInitializer(*Result.Context, *Ctor->getParent(), Ctor);
|
checkMissingBaseClassInitializer(*Result.Context, *Ctor->getParent(), Ctor);
|
||||||
} else if (const auto *Record =
|
} else if (const auto *Record =
|
||||||
|
|
|
@ -501,3 +501,19 @@ struct NegativeImplicitInheritedCtor : NegativeImplicitInheritedCtorBase {
|
||||||
void Bug33557() {
|
void Bug33557() {
|
||||||
NegativeImplicitInheritedCtor I(5);
|
NegativeImplicitInheritedCtor I(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct NegativeDefaultedCtorOutOfDecl {
|
||||||
|
NegativeDefaultedCtorOutOfDecl(const NegativeDefaultedCtorOutOfDecl &);
|
||||||
|
int F;
|
||||||
|
};
|
||||||
|
|
||||||
|
NegativeDefaultedCtorOutOfDecl::NegativeDefaultedCtorOutOfDecl(const NegativeDefaultedCtorOutOfDecl &) = default;
|
||||||
|
|
||||||
|
struct PositiveDefaultConstructorOutOfDecl {
|
||||||
|
PositiveDefaultConstructorOutOfDecl();
|
||||||
|
int F;
|
||||||
|
// CHECK-FIXES: int F{};
|
||||||
|
};
|
||||||
|
|
||||||
|
PositiveDefaultConstructorOutOfDecl::PositiveDefaultConstructorOutOfDecl() = default;
|
||||||
|
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: constructor does not initialize these fields: F
|
||||||
|
|
Loading…
Reference in New Issue