brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.0 KiB · 15d82b7 Raw
152 lines · cpp
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-variable2 3class A { A(int i); };4// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit5 6// NOLINTBEGIN7class B1 { B1(int i); };8// NOLINTEND9 10// NOLINTBEGIN11// NOLINTEND12// NOLINTBEGIN13class B2 { B2(int i); };14// NOLINTEND15 16// NOLINTBEGIN17// NOLINTBEGIN18class B3 { B3(int i); };19// NOLINTEND20// NOLINTEND21 22// NOLINTBEGIN23// NOLINTBEGIN24// NOLINTEND25class B4 { B4(int i); };26// NOLINTEND27 28// NOLINTBEGIN29// NOLINTEND30class B5 { B5(int i); };31// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit32 33// NOLINTBEGIN(google-explicit-constructor)34class C1 { C1(int i); };35// NOLINTEND(google-explicit-constructor)36 37// NOLINTBEGIN()38class C2 { C2(int i); };39// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit40// NOLINTEND()41 42// NOLINTBEGIN(*)43class C3 { C3(int i); };44// NOLINTEND(*)45 46// NOLINTBEGIN(some-other-check)47class C4 { C4(int i); };48// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit49// NOLINTEND(some-other-check)50 51// NOLINTBEGIN(some-other-check, google-explicit-constructor)52class C5 { C5(int i); };53// NOLINTEND(some-other-check, google-explicit-constructor)54 55// NOLINTBEGIN(google-explicit-constructor)56// NOLINTBEGIN(some-other-check)57class C6 { C6(int i); };58// NOLINTEND(some-other-check)59// NOLINTEND(google-explicit-constructor)60 61// NOLINTBEGIN(google-explicit-constructor)62// NOLINTBEGIN63class C7 { C7(int i); };64// NOLINTEND65// NOLINTEND(google-explicit-constructor)66 67// NOLINTBEGIN68// NOLINTBEGIN(google-explicit-constructor)69class C8 { C8(int i); };70// NOLINTEND(google-explicit-constructor)71// NOLINTEND72 73// NOLINTBEGIN(not-closed-bracket-is-treated-as-skip-all74class C9 { C9(int i); };75// NOLINTEND(not-closed-bracket-is-treated-as-skip-all76 77// NOLINTBEGIN without-brackets-skip-all, another-check78class C10 { C10(int i); };79// NOLINTEND without-brackets-skip-all, another-check80 81#define MACRO(X) class X { X(int i); };82 83MACRO(D1)84// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit85// CHECK-MESSAGES: :[[@LINE-4]]:28: note: expanded from macro 'MACRO86 87// NOLINTBEGIN88MACRO(D2)89// NOLINTEND90 91#define MACRO_NOARG class E { E(int i); };92 93// NOLINTBEGIN94MACRO_NOARG95// NOLINTEND96 97// NOLINTBEGIN98#define MACRO_WRAPPED_WITH_NO_LINT class I { I(int i); };99// NOLINTEND100 101MACRO_WRAPPED_WITH_NO_LINT102 103#define MACRO_NO_LINT_INSIDE_MACRO \104  /* NOLINTBEGIN */                \105  class J { J(int i); };           \106  /* NOLINTEND */107 108MACRO_NO_LINT_INSIDE_MACRO109 110// NOLINTBEGIN(google*)111class C11 { C11(int i); };112// NOLINTEND(google*)113 114// NOLINTBEGIN(*explicit-constructor)115class C12 { C12(int i); };116// NOLINTEND(*explicit-constructor)117 118// NOLINTBEGIN(*explicit*)119class C13 { C13(int i); };120// NOLINTEND(*explicit*)121 122// NOLINTBEGIN(-explicit-constructor)123class C14 { C14(int x); };124// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: single-argument constructors must be marked explicit125// NOLINTEND(-explicit-constructor)126 127// NOLINTBEGIN(google*,-google*)128class C15 { C15(int x); };129// NOLINTEND(google*,-google*)130 131// NOLINTBEGIN(*,-google*)132class C16 { C16(int x); };133// NOLINTEND(*,-google*)134 135int 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)139int 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)144int array3[10];145// NOLINTEND(cppcoreguidelines-avoid-c-arrays,modernize-avoid-c-arrays)146 147// NOLINTBEGIN(*-avoid-c-arrays)148int array4[10];149// NOLINTEND(*-avoid-c-arrays)150 151// CHECK-MESSAGES: Suppressed 26 warnings (26 NOLINT).152