88 lines · cpp
1// NOLINTNEXTLINE2class A { A(int i); };3 4class B { B(int i); };5// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit6 7// NOLINTNEXTLINE8class C { C(int i); };9 10// NOLINTNEXTLINE(for-some-other-check)11class D { D(int i); };12// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit13 14// NOLINTNEXTLINE()15class D1 { D1(int i); };16// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit17 18// NOLINTNEXTLINE(*)19class D2 { D2(int i); };20 21// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all22class D3 { D3(int i); };23 24// NOLINTNEXTLINE(google-explicit-constructor)25class D4 { D4(int i); };26 27// NOLINTNEXTLINE(some-check, google-explicit-constructor)28class D5 { D5(int i); };29 30// NOLINTNEXTLINE without-brackets-skip-all, another-check31class D6 { D6(int i); };32 33// NOLINTNEXTLINE34 35class E { E(int i); };36// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit37 38// NOLINTNEXTLINE39//40class F { F(int i); };41// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit42 43#define MACRO(X) class X { X(int i); };44MACRO(G)45// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit46// NOLINTNEXTLINE47MACRO(H)48 49#define MACRO_NOARG class I { I(int i); };50// NOLINTNEXTLINE51MACRO_NOARG52 53// NOLINTNEXTLINE(google*)54class I1 { I1(int i); };55 56// NOLINTNEXTLINE(*explicit-constructor)57class I2 { I2(int i); };58 59// NOLINTNEXTLINE(*explicit*)60class I3 { I3(int i); };61 62// NOLINTNEXTLINE(-explicit-constructor)63class I4 { I4(int x); };64// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit65 66// NOLINTNEXTLINE(google*,-google*)67class I5 { I5(int x); };68 69// NOLINTNEXTLINE(*,-google*)70class I6 { I6(int x); };71 72int array1[10];73// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array' instead [cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays]74 75// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays)76int array2[10];77// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]78 79// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)80int array3[10];81 82// NOLINTNEXTLINE(*-avoid-c-arrays)83int array4[10];84 85// CHECK-MESSAGES: Suppressed 19 warnings (19 NOLINT)86 87// RUN: %check_clang_tidy %s google-explicit-constructor,clang-diagnostic-unused-variable,cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays %t -- -extra-arg=-Wunused-variable88