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