| 1 |
.. title:: clang-tidy - llvmlibc-restrict-system-libc-headers |
| 2 |
|
| 3 |
llvmlibc-restrict-system-libc-headers |
| 4 |
===================================== |
| 5 |
|
| 6 |
Finds includes of system libc headers not provided by the compiler within |
| 7 |
llvm-libc implementations. |
| 8 |
|
| 9 |
.. code-block:: c++ |
| 10 |
|
| 11 |
#include <stdio.h> // Not allowed because it is part of system libc. |
| 12 |
#include <stddef.h> // Allowed because it is provided by the compiler. |
| 13 |
#include "internal/stdio.h" // Allowed because it is NOT part of system libc. |
| 14 |
|
| 15 |
|
| 16 |
This check is necessary because accidentally including system libc headers can |
| 17 |
lead to subtle and hard to detect bugs. For example consider a system libc |
| 18 |
whose ``dirent`` struct has slightly different field ordering than llvm-libc. |
| 19 |
While this will compile successfully, this can cause issues during runtime |
| 20 |
because they are ABI incompatible. |
| 21 |
|
| 22 |
Options |
| 23 |
------- |
| 24 |
|
| 25 |
.. option:: Includes |
| 26 |
|
| 27 |
A string containing a comma separated glob list of allowed include |
| 28 |
filenames. Similar to the -checks glob list for running clang-tidy itself, |
| 29 |
the two wildcard characters are `*` and `-`, to include and exclude globs, |
| 30 |
respectively. The default is `-*`, which disallows all includes. |
| 31 |
|
| 32 |
This can be used to allow known safe includes such as Linux development |
| 33 |
headers. See :doc:`portability-restrict-system-includes |
| 34 |
<../portability/restrict-system-includes>` for more |
| 35 |
details. |