164 lines · cpp
1// RUN: %check_clang_tidy -std=c++11-or-later %s modernize-deprecated-headers %t -- -extra-arg-before=-isystem%S/Inputs/deprecated-headers2 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' instead8// 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' instead11// 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' instead14// 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' instead17// 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' instead20// 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' instead23// 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' instead26// 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' instead29// 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' instead32// 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' instead35// 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' instead38// 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' instead41// 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' instead44// 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' instead47// 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' instead50// 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' instead53// 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' instead56// 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' instead59// 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' instead62// 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' instead65// 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' instead68// 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' instead71// CHECK-FIXES: #include <cwctype>72 73// Headers that have no effect in C++; remove them74#include <stdalign.h> // <stdalign.h>75// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdalign.h' has no effect in C++; consider removing it76// 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 it79// 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 it82// 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' instead86// 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' instead89// 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' instead92// 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' instead95// 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' instead98// 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' instead101// 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' instead104// 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' instead107// 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' instead110// 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' instead113// 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' instead116// 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' instead119// 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' instead122// 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' instead125// 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' instead128// 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' instead131// 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' instead134// 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' instead137// 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' instead140// 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' instead143// 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' instead146// 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' instead149// 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' instead152// CHECK-FIXES: #include <cwctype>153 154// Headers that have no effect in C++; remove them155#include "stdalign.h" // "stdalign.h"156// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdalign.h' has no effect in C++; consider removing it157// 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 it160// 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 it163// CHECK-FIXES: // "iso646.h"164