[clang-tools-extra] r233702 - [clang-tidy] Clarify message for the google-explicit-constructor check
Alexander Kornienko
alexfh at google.com
Tue Mar 31 09:24:44 PDT 2015
Author: alexfh
Date: Tue Mar 31 11:24:44 2015
New Revision: 233702
URL: http://llvm.org/viewvc/llvm-project?rev=233702&view=rev
Log:
[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.
Modified:
clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp
Modified: clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp?rev=233702&r1=233701&r2=233702&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructorCheck.cpp Tue Mar 31 11:24:44 2015
@@ -113,8 +113,12 @@ void ExplicitConstructorCheck::check(con
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 ");
}
Modified: clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp?rev=233702&r1=233701&r2=233702&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp Tue Mar 31 11:24:44 2015
@@ -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 {
More information about the cfe-commits
mailing list