149 lines · cpp
1// RUN: %check_clang_tidy -std=c++98 %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 <float.h>16// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'float.h'; consider using 'cfloat' instead17// 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' instead20// 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' instead23// 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' instead26// 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' instead29// 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' instead32// 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' instead35// 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' instead38// 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' instead41// 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' instead44// 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' instead47// 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' instead50// 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' instead53// 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' instead56// CHECK-FIXES: #include <cwctype>57 58// Headers that have no effect in C++; remove them59#include <stdalign.h> // <stdalign.h>60// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdalign.h' has no effect in C++; consider removing it61// 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 it64// 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 it67// 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' instead79// 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' instead82// 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' instead85// 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' instead88// 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' instead91// 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' instead94// 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' instead97// 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' instead100// 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' instead103// 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' instead106// 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' instead109// 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' instead112// 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' instead115// 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' instead118// 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' instead121// 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' instead124// 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' instead127// 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' instead130// CHECK-FIXES: #include <cwctype>131 132// Headers that have no effect in C++; remove them133#include "stdalign.h" // "stdalign.h"134// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdalign.h' has no effect in C++; consider removing it135// 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 it138// 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 it141// CHECK-FIXES: // "iso646.h"142 143// Headers deprecated since C++11; expect no diagnostics144#include "fenv.h"145#include "inttypes.h"146#include "stdint.h"147#include "tgmath.h"148#include "uchar.h"149