1 // RUN: %check_clang_tidy %s google-explicit-constructor,clang-diagnostic-unused-variable,cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays %t -- -extra-arg=-Wunused-variable 2 3 class A { A(int i); }; 4 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit 5 6 // NOLINTBEGIN 7 class B1 { B1(int i); }; 8 // NOLINTEND 9 10 // NOLINTBEGIN 11 // NOLINTEND 12 // NOLINTBEGIN 13 class B2 { B2(int i); }; 14 // NOLINTEND 15 16 // NOLINTBEGIN 17 // NOLINTBEGIN 18 class B3 { B3(int i); }; 19 // NOLINTEND 20 // NOLINTEND 21 22 // NOLINTBEGIN 23 // NOLINTBEGIN 24 // NOLINTEND 25 class B4 { B4(int i); }; 26 // NOLINTEND 27 28 // NOLINTBEGIN 29 // NOLINTEND 30 class B5 { B5(int i); }; 31 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit 32 33 // NOLINTBEGIN(google-explicit-constructor) 34 class C1 { C1(int i); }; 35 // NOLINTEND(google-explicit-constructor) 36 37 // NOLINTBEGIN() 38 class C2 { C2(int i); }; 39 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit 40 // NOLINTEND() 41 42 // NOLINTBEGIN(*) 43 class C3 { C3(int i); }; 44 // NOLINTEND(*) 45 46 // NOLINTBEGIN(some-other-check) 47 class C4 { C4(int i); }; 48 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit 49 // NOLINTEND(some-other-check) 50 51 // NOLINTBEGIN(some-other-check, google-explicit-constructor) 52 class C5 { C5(int i); }; 53 // NOLINTEND(some-other-check, google-explicit-constructor) 54 55 // NOLINTBEGIN(google-explicit-constructor) 56 // NOLINTBEGIN(some-other-check) 57 class C6 { C6(int i); }; 58 // NOLINTEND(some-other-check) 59 // NOLINTEND(google-explicit-constructor) 60 61 // NOLINTBEGIN(google-explicit-constructor) 62 // NOLINTBEGIN 63 class C7 { C7(int i); }; 64 // NOLINTEND 65 // NOLINTEND(google-explicit-constructor) 66 67 // NOLINTBEGIN 68 // NOLINTBEGIN(google-explicit-constructor) 69 class C8 { C8(int i); }; 70 // NOLINTEND(google-explicit-constructor) 71 // NOLINTEND 72 73 // NOLINTBEGIN(not-closed-bracket-is-treated-as-skip-all 74 class C9 { C9(int i); }; 75 // NOLINTEND(not-closed-bracket-is-treated-as-skip-all 76 77 // NOLINTBEGIN without-brackets-skip-all, another-check 78 class C10 { C10(int i); }; 79 // NOLINTEND without-brackets-skip-all, another-check 80 81 #define MACRO(X) class X { X(int i); }; 82 83 MACRO(D1) 84 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit 85 // CHECK-MESSAGES: :[[@LINE-4]]:28: note: expanded from macro 'MACRO 86 87 // NOLINTBEGIN 88 MACRO(D2) 89 // NOLINTEND 90 91 #define MACRO_NOARG class E { E(int i); }; 92 93 // NOLINTBEGIN 94 MACRO_NOARG 95 // NOLINTEND 96 97 // NOLINTBEGIN 98 #define MACRO_WRAPPED_WITH_NO_LINT class I { I(int i); }; 99 // NOLINTEND 100 101 MACRO_WRAPPED_WITH_NO_LINT 102 103 #define MACRO_NO_LINT_INSIDE_MACRO \ 104 /* NOLINTBEGIN */ \ 105 class J { J(int i); }; \ 106 /* NOLINTEND */ 107 108 MACRO_NO_LINT_INSIDE_MACRO 109 110 // NOLINTBEGIN(google*) 111 class C11 { C11(int i); }; 112 // NOLINTEND(google*) 113 114 // NOLINTBEGIN(*explicit-constructor) 115 class C12 { C12(int i); }; 116 // NOLINTEND(*explicit-constructor) 117 118 // NOLINTBEGIN(*explicit*) 119 class C13 { C13(int i); }; 120 // NOLINTEND(*explicit*) 121 122 // NOLINTBEGIN(-explicit-constructor) 123 class C14 { C14(int x); }; 124 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: single-argument constructors must be marked explicit 125 // NOLINTEND(-explicit-constructor) 126 127 // NOLINTBEGIN(google*,-google*) 128 class C15 { C15(int x); }; 129 // NOLINTEND(google*,-google*) 130 131 // NOLINTBEGIN(*,-google*) 132 class C16 { C16(int x); }; 133 // NOLINTEND(*,-google*) 134 135 int array1[10]; 136 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array' instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays] 137 138 // NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays) 139 int array2[10]; 140 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays] 141 // NOLINTEND(cppcoreguidelines-avoid-c-arrays) 142 143 // NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays) 144 int array3[10]; 145 // NOLINTEND(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays) 146 147 // NOLINTBEGIN(*-avoid-c-arrays) 148 int array4[10]; 149 // NOLINTEND(*-avoid-c-arrays) 150 151 // CHECK-MESSAGES: Suppressed 26 warnings (26 NOLINT). 152