1 // REQUIRES: static-analyzer, libclang_include_clang_tools_extra
2 // RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin -Xclang clang-tidy -Xclang -plugin-arg-clang-tidy -Xclang -checks='-*,google-explicit-constructor,clang-diagnostic-unused-variable,clang-analyzer-core.UndefinedBinaryOperatorResult' -Wunused-variable -I%S/Inputs/nolint 2>&1 | FileCheck %s
3
4 #include "trigger_warning.h"
I(int & Out)5 void I(int& Out) {
6 int In;
7 A1(In, Out);
8 }
9 // CHECK-NOT: trigger_warning.h:{{.*}} warning
10 // CHECK-NOT: :[[@LINE-4]]:{{.*}} note
11
12 class A { A(int i); };
13 // CHECK-DAG: :[[@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-DAG: :[[@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-DAG: :[[@LINE-1]]:7: warning: unused variable 'i' [-Wunused-variable]
33 // 31:7: warning: unused variable 'i' [-Wunused-variable]
34 // int j; // NOLINT
35 // int k; // NOLINT(clang-diagnostic-unused-variable)
36 }
37
38 #define MACRO(X) class X { X(int i); };
39 MACRO(D)
40 // CHECK-DAG: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
41 MACRO(E) // NOLINT
42
43 #define MACRO_NOARG class F { F(int i); };
44 MACRO_NOARG // NOLINT
45
46 #define MACRO_NOLINT class G { G(int i); }; // NOLINT
47 MACRO_NOLINT
48
49 #define DOUBLE_MACRO MACRO(H) // NOLINT
50 DOUBLE_MACRO
51