[libc-commits] [clang-tools-extra] [libc] [libc][docs][NFC] Remove dead files and consolidate check.rst (PR #194442)

Jeff Bailey via libc-commits libc-commits at lists.llvm.org
Thu Apr 30 05:26:32 PDT 2026


================
@@ -289,3 +289,123 @@ Example usage:
 Having hidden visibility on the namespace ensures extern declarations in a given TU
 have known visibility and never generate GOT indirections. The attribute guarantees
 this independently of global compile options and build systems.
+
+.. _clang_tidy_checks:
+
+Static Analysis & Clang-Tidy
+=============================
+
+Configuration
+-------------
+
+LLVM libc uses layered ``.clang-tidy`` configuration files:
+
+- ``libc/.clang-tidy``: baseline checks for the ``libc`` subtree (currently
+  focuses on identifier naming conventions).
+- ``libc/src/.clang-tidy``: adds LLVM-libc-specific checks (``llvmlibc-*``) for
+  implementation code under ``libc/src`` and also enables
+  ``readability-identifier-naming`` and ``llvm-header-guard``. Diagnostics from
+  ``llvmlibc-*`` checks are treated as errors.
+
+LLVM-libc checks
+----------------
+
+restrict-system-libc-headers
+----------------------------
+Check name: ``llvmlibc-restrict-system-libc-headers``.
+
+One of libc-project's design goals is to use kernel headers and compiler
+provided headers to prevent code duplication on a per platform basis. This
+presents a problem when writing implementations since system libc headers are
+easy to include accidentally and we can't just use the ``-nostdinc`` flag.
+Improperly included system headers can introduce runtime errors because the C
+standard outlines function prototypes and behaviors but doesn't define
+underlying implementation details such as the layout of a struct.
+
+This check prevents accidental inclusion of system libc headers when writing a
+libc implementation.
+
+.. code-block:: c++
+
+   #include <stdio.h>            // Not allowed because it is part of system libc.
+   #include <stddef.h>           // Allowed because it is provided by the compiler.
+   #include "internal/stdio.h"   // Allowed because it is NOT part of system libc.
----------------
kaladron wrote:

Since this reflects the state of the docs as they are today, I'd like to do this in a subsequent PR.  I've filed https://github.com/llvm/llvm-project/issues/195067 to make sure this doesn't get lost.

https://github.com/llvm/llvm-project/pull/194442


More information about the libc-commits mailing list