Debian Codegraph @

clang-tools-extra/test/clang-tidy/checkers/modernize/deprecated-headers-extern-c.cpp

raw
1
2 // Copy the 'mylib.h' to a directory under the build directory. This is
3 // required, since the relative order of the emitted diagnostics depends on the
4 // absolute file paths which is sorted by clang-tidy prior emitting.
5 //
6 // RUN: mkdir -p %t/sys && mkdir -p %t/usr \
7 // RUN: && cp %S/Inputs/deprecated-headers/mysystemlib.h %t/sys/mysystemlib.h \
8 // RUN: && cp %S/Inputs/deprecated-headers/mylib.h %t/usr/mylib.h
9
10 // RUN: %check_clang_tidy -std=c++11 %s modernize-deprecated-headers %t \
11 // RUN: -check-suffixes=DEFAULT \
12 // RUN: --header-filter='.*' --system-headers \
13 // RUN: -- -I %t/usr -isystem %t/sys -isystem %S/Inputs/deprecated-headers
14
15 // RUN: %check_clang_tidy -std=c++11 %s modernize-deprecated-headers %t \
16 // RUN: -check-suffixes=DEFAULT,CHECK-HEADER-FILE \
17 // RUN: -config="{CheckOptions: {modernize-deprecated-headers.CheckHeaderFile: 'true'}}" \
18 // RUN: --header-filter='.*' --system-headers \
19 // RUN: -- -I %t/usr -isystem %t/sys -isystem %S/Inputs/deprecated-headers
20
21 // REQUIRES: system-linux
22
23 #define EXTERN_C extern "C"
24
25 extern "C++" {
26 // We should still have the warnings here.
27 #include <stdbool.h>
28 // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
29 }
30
31 #include <assert.h>
32 // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
33
34 #include <stdbool.h>
35 // CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it [modernize-deprecated-headers]
36
37 #include <mysystemlib.h> // no-warning: Don't warn into system headers.
38
39 #include <mylib.h>
40 // CHECK-MESSAGES-CHECK-HEADER-FILE: mylib.h:1:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
41
42 namespace wrapping {
43 extern "C" {
44 #include <assert.h> // no-warning
45 #include <mylib.h> // no-warning
46 #include <stdbool.h> // no-warning
47 }
48 } // namespace wrapping
49
50 extern "C" {
51 namespace wrapped {
52 #include <assert.h> // no-warning
53 #include <mylib.h> // no-warning
54 #include <stdbool.h> // no-warning
55 } // namespace wrapped
56 }
57
58 namespace wrapping {
59 extern "C" {
60 namespace wrapped {
61 #include <assert.h> // no-warning
62 #include <mylib.h> // no-warning
63 #include <stdbool.h> // no-warning
64 } // namespace wrapped
65 }
66 } // namespace wrapping
67
68 EXTERN_C {
69 #include <assert.h> // no-warning
70 #include <mylib.h> // no-warning
71 #include <stdbool.h> // no-warning
72 }