1 // REQUIRES: static-analyzer
2 // RUN: %check_clang_tidy %s google-explicit-constructor,clang-diagnostic-unused-variable,clang-analyzer-core.UndefinedBinaryOperatorResult %t -- -extra-arg=-Wunused-variable -- -I%S/Inputs/nolint
3 
4 #include "trigger_warning.h"
I(int & Out)5 void I(int& Out) {
6   int In;
7   A1(In, Out);
8 }
9 // CHECK-MESSAGES-NOT: trigger_warning.h:{{.*}} warning
10 // CHECK-MESSAGES-NOT: :[[@LINE-4]]:{{.*}} note
11 
12 class A { A(int i); };
13 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
14 
15 class B { B(int i); }; // NOLINT
16 
17 class C { C(int i); }; // NOLINT(for-some-other-check)
18 // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
19 
20 class C1 { C1(int i); }; // NOLINT(*)
21 
22 class C2 { C2(int i); }; // NOLINT(not-closed-bracket-is-treated-as-skip-all
23 
24 class C3 { C3(int i); }; // NOLINT(google-explicit-constructor)
25 
26 class C4 { C4(int i); }; // NOLINT(some-check, google-explicit-constructor)
27 
28 class C5 { C5(int i); }; // NOLINT without-brackets-skip-all, another-check
29 
f()30 void f() {
31   int i;
32 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: unused variable 'i' [clang-diagnostic-unused-variable]
33   int j; // NOLINT
34   int k; // NOLINT(clang-diagnostic-unused-variable)
35 }
36 
37 #define MACRO(X) class X { X(int i); };
38 MACRO(D)
39 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
40 MACRO(E) // NOLINT
41 
42 #define MACRO_NOARG class F { F(int i); };
43 MACRO_NOARG // NOLINT
44 
45 #define MACRO_NOLINT class G { G(int i); }; // NOLINT
46 MACRO_NOLINT
47 
48 #define DOUBLE_MACRO MACRO(H) // NOLINT
49 DOUBLE_MACRO
50 
51 // CHECK-MESSAGES: Suppressed 13 warnings (13 NOLINT)
52