xref: /llvm-project/clang-tools-extra/test/clang-tidy/infrastructure/nolintnextline.cpp (revision 5fa742eeed0821baf864d23f237ff1b481e1ae11)
1 // NOLINTNEXTLINE
2 class A { A(int i); };
3 
4 class B { B(int i); };
5 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
6 
7 // NOLINTNEXTLINE
8 class C { C(int i); };
9 
10 // NOLINTNEXTLINE(for-some-other-check)
11 class D { D(int i); };
12 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
13 
14 // NOLINTNEXTLINE()
15 class D1 { D1(int i); };
16 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
17 
18 // NOLINTNEXTLINE(*)
19 class D2 { D2(int i); };
20 
21 // NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
22 class D3 { D3(int i); };
23 
24 // NOLINTNEXTLINE(google-explicit-constructor)
25 class D4 { D4(int i); };
26 
27 // NOLINTNEXTLINE(some-check, google-explicit-constructor)
28 class D5 { D5(int i); };
29 
30 // NOLINTNEXTLINE without-brackets-skip-all, another-check
31 class D6 { D6(int i); };
32 
33 // NOLINTNEXTLINE
34 
35 class E { E(int i); };
36 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
37 
38 // NOLINTNEXTLINE
39 //
40 class F { F(int i); };
41 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
42 
43 #define MACRO(X) class X { X(int i); };
44 MACRO(G)
45 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
46 // NOLINTNEXTLINE
47 MACRO(H)
48 
49 #define MACRO_NOARG class I { I(int i); };
50 // NOLINTNEXTLINE
51 MACRO_NOARG
52 
53 // NOLINTNEXTLINE(google*)
54 class I1 { I1(int i); };
55 
56 // NOLINTNEXTLINE(*explicit-constructor)
57 class I2 { I2(int i); };
58 
59 // NOLINTNEXTLINE(*explicit*)
60 class I3 { I3(int i); };
61 
62 // NOLINTNEXTLINE(-explicit-constructor)
63 class I4 { I4(int x); };
64 // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
65 
66 // NOLINTNEXTLINE(google*,-google*)
67 class I5 { I5(int x); };
68 
69 // NOLINTNEXTLINE(*,-google*)
70 class I6 { I6(int x); };
71 
72 int 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)
76 int 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)
80 int array3[10];
81 
82 // NOLINTNEXTLINE(*-avoid-c-arrays)
83 int 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-variable
88