mirror of
https://github.com/intel/llvm.git
synced 2026-01-15 04:17:17 +08:00
[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:
@@ -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 ");
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user