[clang-tidy] Clarify message for the google-explicit-constructor check

Use "constructors that are callable with a single argument" instead of
"single-argument constructors" when referring to constructors using default
arguments or parameter packs.

llvm-svn: 233702
This commit is contained in:
Alexander Kornienko
2015-03-31 16:24:44 +00:00
parent d399d94837
commit 0b024619df
2 changed files with 11 additions and 2 deletions

View File

@@ -113,8 +113,12 @@ void ExplicitConstructorCheck::check(const MatchFinder::MatchResult &Result) {
takesInitializerList)
return;
bool SingleArgument =
Ctor->getNumParams() == 1 && !Ctor->getParamDecl(0)->isParameterPack();
SourceLocation Loc = Ctor->getLocation();
diag(Loc, "single-argument constructors must be explicit")
diag(Loc, SingleArgument ? "single-argument constructors must be explicit"
: "constructors that are callable with a single "
"argument must be marked explicit")
<< FixItHint::CreateInsertion(Loc, "explicit ");
}

View File

@@ -49,8 +49,13 @@ struct A {
// CHECK-FIXES: {{^ }}explicit A(int x1) {}
A(double x2, double y = 3.14) {}
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: single-argument constructors
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructors that are callable with a single argument must be marked explicit [google-explicit-constructor]
// CHECK-FIXES: {{^ }}explicit A(double x2, double y = 3.14) {}
template <typename... T>
A(T&&... args);
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructors that are callable with a single argument
// CHECK-FIXES: {{^ }}explicit A(T&&... args);
};
struct B {