[clang-tools-extra] r222924 - [clang-tidy] More tests for the google-explicit-constructor check
Alexander Kornienko
alexfh at google.com
Fri Nov 28 09:31:51 PST 2014
Author: alexfh
Date: Fri Nov 28 11:31:51 2014
New Revision: 222924
URL: http://llvm.org/viewvc/llvm-project?rev=222924&view=rev
Log:
[clang-tidy] More tests for the google-explicit-constructor check
Modified:
clang-tools-extra/trunk/test/clang-tidy/google-explicit-constructor.cpp
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=222924&r1=222923&r2=222924&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 Fri Nov 28 11:31:51 2014
@@ -36,7 +36,6 @@ namespace std {
struct A {
A() {}
A(int x, int y) {}
- A(std::initializer_list<int> list1) {}
explicit A(void *x) {}
explicit A(void *x, void *y) {}
@@ -45,10 +44,6 @@ struct A {
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: copy constructor should not be declared explicit [google-explicit-constructor]
// CHECK-FIXES: {{^ }}A(const A& a) {}
- explicit A(std::initializer_list<double> list2) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: initializer-list constructor should not be declared explicit [google-explicit-constructor]
- // CHECK-FIXES: {{^ }}A(std::initializer_list<double> list2) {}
-
A(int x1) {}
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: single-argument constructors must be explicit [google-explicit-constructor]
// CHECK-FIXES: {{^ }}explicit A(int x1) {}
@@ -57,3 +52,29 @@ struct A {
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: single-argument constructors must be explicit
// CHECK-FIXES: {{^ }}explicit A(double x2, double y = 3.14) {}
};
+
+struct B {
+ B(std::initializer_list<int> list1) {}
+ B(const std::initializer_list<unsigned> &list2) {}
+ B(std::initializer_list<unsigned> &&list3) {}
+
+ explicit B(::std::initializer_list<double> list4) {}
+ // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: initializer-list constructor should not be declared explicit [google-explicit-constructor]
+ // CHECK-FIXES: {{^ }}B(::std::initializer_list<double> list4) {}
+
+ explicit B(const ::std::initializer_list<char> &list5) {}
+ // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: initializer-list constructor should not be declared explicit [google-explicit-constructor]
+ // CHECK-FIXES: {{^ }}B(const ::std::initializer_list<char> &list5) {}
+
+ explicit B(::std::initializer_list<char> &&list6) {}
+ // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: initializer-list constructor should not be declared explicit [google-explicit-constructor]
+ // CHECK-FIXES: {{^ }}B(::std::initializer_list<char> &&list6) {}
+};
+
+using namespace std;
+
+struct C {
+ C(initializer_list<int> list1) {}
+ C(const initializer_list<unsigned> &list2) {}
+ C(initializer_list<unsigned> &&list3) {}
+};
More information about the cfe-commits
mailing list