brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 6c35cd4 Raw
84 lines · plain
1.. title:: clang-tidy - modernize-deprecated-headers2 3modernize-deprecated-headers4============================5 6Some headers from C library were deprecated in C++ and are no longer welcome in7C++ codebases. Some have no effect in C++. For more details refer to the C++148Standard [depr.c.headers] section.9 10This check replaces C standard library headers with their C++ alternatives and11removes redundant ones.12 13.. code-block:: c++14 15  // C++ source file...16  #include <assert.h>17  #include <stdbool.h>18 19  // becomes20 21  #include <cassert>22  // No 'stdbool.h' here.23 24Important note: the Standard doesn't guarantee that the C++ headers declare all25the same functions in the global namespace. The check in its current form can26break the code that uses library symbols from the global namespace.27 28* `<assert.h>`29* `<complex.h>`30* `<ctype.h>`31* `<errno.h>`32* `<fenv.h>`     // deprecated since C++1133* `<float.h>`34* `<inttypes.h>`35* `<limits.h>`36* `<locale.h>`37* `<math.h>`38* `<setjmp.h>`39* `<signal.h>`40* `<stdarg.h>`41* `<stddef.h>`42* `<stdint.h>`43* `<stdio.h>`44* `<stdlib.h>`45* `<string.h>`46* `<tgmath.h>`   // deprecated since C++1147* `<time.h>`48* `<uchar.h>`    // deprecated since C++1149* `<wchar.h>`50* `<wctype.h>`51 52If the specified standard is older than C++11 the check will only replace53headers deprecated before C++11, otherwise -- every header that appeared in54the previous list.55 56These headers don't have effect in C++:57 58* `<iso646.h>`59* `<stdalign.h>`60* `<stdbool.h>`61 62The checker ignores `include` directives within `extern "C" { ... }` blocks,63since a library might want to expose some API for C and C++ libraries.64 65.. code-block:: c++66 67  // C++ source file...68  extern "C" {69  #include <assert.h>  // Left intact.70  #include <stdbool.h> // Left intact.71  }72 73Options74-------75 76.. option:: CheckHeaderFile77 78   `clang-tidy` cannot know if the header file included by the currently79   analyzed C++ source file is not included by any other C source files.80   Hence, to omit false-positives and wrong fixit-hints, we ignore emitting81   reports into header files. One can set this option to `true` if they know82   that the header files in the project are only used by C++ source files.83   Default is `false`.84