[libcxx-commits] [clang] [compiler-rt] [libcxx] [clang] Add unistd fortify checks and analyzer size constraints (PR #196499)

Denys Fedoryshchenko via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 12 00:58:20 PDT 2026


================
@@ -3760,6 +3846,19 @@ def VFork : LibBuiltin<"unistd.h"> {
   let Prototype = "pid_t()";
 }
 
+// unistd.h I/O functions (read/write/pread/pwrite/readlink/readlinkat/getcwd)
+// are intentionally not declared as builtins.
+//   * "read", "write", "readlink", "readlinkat", and "getcwd" are common
+//     identifiers (or names that appear in asm-label wrappers); declaring them
+//     as Clang builtins makes harmless local declarations trigger
+//     -Wincompatible-library-redeclaration (an error under -Werror).
+//   * pread/pwrite prototypes use off_t, whose width is platform- and
+//     macro-dependent (notably _FILE_OFFSET_BITS); a fixed builtin signature
+//     would clash with the system header on some targets.
+// Fortify checks for all of these are dispatched by name in
+// Sema::checkFortifiedBuiltinMemoryFunction, gated on a full prototype
+// match against the POSIX signature.
+
----------------
nuclearcat wrote:

No, this wasn’t requested elsewhere. I added it while documenting the places where this differs from Colin’s original patch, mainly to explain why these functions are handled through the name-dispatch path instead of builtins.
That rationale is probably better suited for the PR discussion than for Builtins.td. I will remove the comment from the patch.


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


More information about the libcxx-commits mailing list