[clang-tidy] Verify some conditions in a matcher instead of check(). NFC

llvm-svn: 298057
This commit is contained in:
Alexander Kornienko 2017-03-17 09:47:05 +00:00
parent 913ffeb5ba
commit c7c9b75804
1 changed files with 7 additions and 6 deletions

View File

@ -24,8 +24,11 @@ void ExplicitConstructorCheck::registerMatchers(MatchFinder *Finder) {
// provide any benefit to other languages, despite being benign.
if (!getLangOpts().CPlusPlus)
return;
Finder->addMatcher(cxxConstructorDecl(unless(isInstantiated())).bind("ctor"),
this);
Finder->addMatcher(
cxxConstructorDecl(unless(anyOf(isImplicit(), // Compiler-generated.
isDeleted(), isInstantiated())))
.bind("ctor"),
this);
Finder->addMatcher(
cxxConversionDecl(unless(anyOf(isExplicit(), // Already marked explicit.
isImplicit(), // Compiler-generated.
@ -99,10 +102,8 @@ void ExplicitConstructorCheck::check(const MatchFinder::MatchResult &Result) {
}
const auto *Ctor = Result.Nodes.getNodeAs<CXXConstructorDecl>("ctor");
// Do not be confused: isExplicit means 'explicit' keyword is present,
// isImplicit means that it's a compiler-generated constructor.
if (Ctor->isOutOfLine() || Ctor->isImplicit() || Ctor->isDeleted() ||
Ctor->getNumParams() == 0 || Ctor->getMinRequiredArguments() > 1)
if (Ctor->isOutOfLine() || Ctor->getNumParams() == 0 ||
Ctor->getMinRequiredArguments() > 1)
return;
bool takesInitializerList = isStdInitializerList(