1 | // RUN: %check_clang_tidy -std=c++98 %s modernize-deprecated-headers %t -- -extra-arg-before=-isystem%S/Inputs/deprecated-headers |
2 | |
3 | #include <assert.h> |
4 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers] |
5 | // CHECK-FIXES: {{^}}#include <cassert>{{$}} |
6 | #include <complex.h> |
7 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'complex.h'; consider using 'complex' instead |
8 | // CHECK-FIXES: {{^}}#include <complex>{{$}} |
9 | #include <ctype.h> |
10 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'ctype.h'; consider using 'cctype' instead |
11 | // CHECK-FIXES: {{^}}#include <cctype>{{$}} |
12 | #include <errno.h> |
13 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'errno.h'; consider using 'cerrno' instead |
14 | // CHECK-FIXES: {{^}}#include <cerrno>{{$}} |
15 | #include <float.h> |
16 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'float.h'; consider using 'cfloat' instead |
17 | // CHECK-FIXES: {{^}}#include <cfloat>{{$}} |
18 | #include <limits.h> |
19 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'limits.h'; consider using 'climits' instead |
20 | // CHECK-FIXES: {{^}}#include <climits>{{$}} |
21 | #include <locale.h> |
22 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'locale.h'; consider using 'clocale' instead |
23 | // CHECK-FIXES: {{^}}#include <clocale>{{$}} |
24 | #include <math.h> |
25 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead |
26 | // CHECK-FIXES: {{^}}#include <cmath>{{$}} |
27 | #include <setjmp.h> |
28 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'setjmp.h'; consider using 'csetjmp' instead |
29 | // CHECK-FIXES: {{^}}#include <csetjmp>{{$}} |
30 | #include <signal.h> |
31 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'signal.h'; consider using 'csignal' instead |
32 | // CHECK-FIXES: {{^}}#include <csignal>{{$}} |
33 | #include <stdarg.h> |
34 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdarg.h'; consider using 'cstdarg' instead |
35 | // CHECK-FIXES: {{^}}#include <cstdarg>{{$}} |
36 | #include <stddef.h> |
37 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stddef.h'; consider using 'cstddef' instead |
38 | // CHECK-FIXES: {{^}}#include <cstddef>{{$}} |
39 | #include <stdio.h> |
40 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead |
41 | // CHECK-FIXES: {{^}}#include <cstdio>{{$}} |
42 | #include <stdlib.h> |
43 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdlib.h'; consider using 'cstdlib' instead |
44 | // CHECK-FIXES: {{^}}#include <cstdlib>{{$}} |
45 | #include <string.h> |
46 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'string.h'; consider using 'cstring' instead |
47 | // CHECK-FIXES: {{^}}#include <cstring>{{$}} |
48 | #include <time.h> |
49 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'time.h'; consider using 'ctime' instead |
50 | // CHECK-FIXES: {{^}}#include <ctime>{{$}} |
51 | #include <wchar.h> |
52 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'wchar.h'; consider using 'cwchar' instead |
53 | // CHECK-FIXES: {{^}}#include <cwchar>{{$}} |
54 | #include <wctype.h> |
55 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'wctype.h'; consider using 'cwctype' instead |
56 | // CHECK-FIXES: {{^}}#include <cwctype>{{$}} |
57 | |
58 | // Headers that have no effect in C++; remove them |
59 | #include <stdalign.h> // <stdalign.h> |
60 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdalign.h' has no effect in C++; consider removing it |
61 | // CHECK-FIXES: {{^}}// <stdalign.h>{{$}} |
62 | #include <stdbool.h> // <stdbool.h> |
63 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it |
64 | // CHECK-FIXES: {{^}}// <stdbool.h>{{$}} |
65 | #include <iso646.h> // <iso646.h> |
66 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'iso646.h' has no effect in C++; consider removing it |
67 | // CHECK-FIXES: {{^}}// <iso646.h>{{$}} |
68 | |
69 | // Headers deprecated since C++11: expect no diagnostics. |
70 | #include <fenv.h> |
71 | #include <inttypes.h> |
72 | #include <stdint.h> |
73 | #include <tgmath.h> |
74 | #include <uchar.h> |
75 | |
76 | |
77 | #include "assert.h" |
78 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead |
79 | // CHECK-FIXES: {{^}}#include <cassert>{{$}} |
80 | #include "complex.h" |
81 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'complex.h'; consider using 'complex' instead |
82 | // CHECK-FIXES: {{^}}#include <complex>{{$}} |
83 | #include "ctype.h" |
84 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'ctype.h'; consider using 'cctype' instead |
85 | // CHECK-FIXES: {{^}}#include <cctype>{{$}} |
86 | #include "errno.h" |
87 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'errno.h'; consider using 'cerrno' instead |
88 | // CHECK-FIXES: {{^}}#include <cerrno>{{$}} |
89 | #include "float.h" |
90 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'float.h'; consider using 'cfloat' instead |
91 | // CHECK-FIXES: {{^}}#include <cfloat>{{$}} |
92 | #include "limits.h" |
93 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'limits.h'; consider using 'climits' instead |
94 | // CHECK-FIXES: {{^}}#include <climits>{{$}} |
95 | #include "locale.h" |
96 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'locale.h'; consider using 'clocale' instead |
97 | // CHECK-FIXES: {{^}}#include <clocale>{{$}} |
98 | #include "math.h" |
99 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead |
100 | // CHECK-FIXES: {{^}}#include <cmath>{{$}} |
101 | #include "setjmp.h" |
102 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'setjmp.h'; consider using 'csetjmp' instead |
103 | // CHECK-FIXES: {{^}}#include <csetjmp>{{$}} |
104 | #include "signal.h" |
105 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'signal.h'; consider using 'csignal' instead |
106 | // CHECK-FIXES: {{^}}#include <csignal>{{$}} |
107 | #include "stdarg.h" |
108 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdarg.h'; consider using 'cstdarg' instead |
109 | // CHECK-FIXES: {{^}}#include <cstdarg>{{$}} |
110 | #include "stddef.h" |
111 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stddef.h'; consider using 'cstddef' instead |
112 | // CHECK-FIXES: {{^}}#include <cstddef>{{$}} |
113 | #include "stdio.h" |
114 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead |
115 | // CHECK-FIXES: {{^}}#include <cstdio>{{$}} |
116 | #include "stdlib.h" |
117 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdlib.h'; consider using 'cstdlib' instead |
118 | // CHECK-FIXES: {{^}}#include <cstdlib>{{$}} |
119 | #include "string.h" |
120 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'string.h'; consider using 'cstring' instead |
121 | // CHECK-FIXES: {{^}}#include <cstring>{{$}} |
122 | #include "time.h" |
123 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'time.h'; consider using 'ctime' instead |
124 | // CHECK-FIXES: {{^}}#include <ctime>{{$}} |
125 | #include "wchar.h" |
126 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'wchar.h'; consider using 'cwchar' instead |
127 | // CHECK-FIXES: {{^}}#include <cwchar>{{$}} |
128 | #include "wctype.h" |
129 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'wctype.h'; consider using 'cwctype' instead |
130 | // CHECK-FIXES: {{^}}#include <cwctype> |
131 | |
132 | // Headers that have no effect in C++; remove them |
133 | #include "stdalign.h" // "stdalign.h" |
134 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdalign.h' has no effect in C++; consider removing it |
135 | // CHECK-FIXES: {{^}}// "stdalign.h"{{$}} |
136 | #include "stdbool.h" // "stdbool.h" |
137 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it |
138 | // CHECK-FIXES: {{^}}// "stdbool.h"{{$}} |
139 | #include "iso646.h" // "iso646.h" |
140 | // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'iso646.h' has no effect in C++; consider removing it |
141 | // CHECK-FIXES: {{^}}// "iso646.h"{{$}} |
142 | |
143 | // Headers deprecated since C++11; expect no diagnostics |
144 | #include "fenv.h" |
145 | #include "inttypes.h" |
146 | #include "stdint.h" |
147 | #include "tgmath.h" |
148 | #include "uchar.h" |
149 | |