[clang] [clang][Sema] Add buffer-size checks for unistd I/O functions (PR #224979)
Denys Fedoryshchenko via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 2 03:00:12 PDT 2026
================
@@ -3860,6 +3860,74 @@ def VFork : LibBuiltin<"unistd.h"> {
let Prototype = "pid_t()";
}
+// The unistd I/O signatures vary across targets (ssize_t, off_t and count
+// types). Require a declaration rather than synthesizing a prototype.
+
+def Read : LibBuiltin<"unistd.h"> {
+ let Spellings = ["read"];
+ let Attributes = [IgnoreSignature];
+ // ssize_t(int, void*, size_t); return and count types are target-specific
+ let Prototype = "";
+}
+
+def Write : LibBuiltin<"unistd.h"> {
+ let Spellings = ["write"];
+ let Attributes = [IgnoreSignature];
+ // ssize_t(int, void const*, size_t); return and count types are target-specific
+ let Prototype = "";
+}
+
+def PRead : LibBuiltin<"unistd.h"> {
+ let Spellings = ["pread"];
+ let Attributes = [IgnoreSignature];
+ // ssize_t(int, void*, size_t, off_t); ssize_t and off_t are target-specific
+ let Prototype = "";
+}
+
+def PRead64 : LibBuiltin<"unistd.h"> {
+ let Spellings = ["pread64"];
+ let Attributes = [IgnoreSignature];
+ // ssize_t(int, void*, size_t, off64_t); ssize_t and off64_t are target-specific
+ let Prototype = "";
+}
+
+def PWrite : LibBuiltin<"unistd.h"> {
+ let Spellings = ["pwrite"];
+ let Attributes = [IgnoreSignature];
+ // ssize_t(int, void const*, size_t, off_t);
+ // ssize_t and off_t are target-specific
+ let Prototype = "";
+}
+
+def PWrite64 : LibBuiltin<"unistd.h"> {
+ let Spellings = ["pwrite64"];
+ let Attributes = [IgnoreSignature];
+ // ssize_t(int, void const*, size_t, off64_t);
+ // ssize_t and off64_t are target-specific
+ let Prototype = "";
+}
+
+def ReadLink : LibBuiltin<"unistd.h"> {
+ let Spellings = ["readlink"];
+ let Attributes = [IgnoreSignature];
+ // ssize_t(char const*, char*, size_t); ssize_t is target-specific
+ let Prototype = "";
+}
+
+def ReadLinkAt : LibBuiltin<"unistd.h"> {
+ let Spellings = ["readlinkat"];
+ let Attributes = [IgnoreSignature];
+ // ssize_t(int, char const*, char*, size_t); ssize_t is target-specific
+ let Prototype = "";
+}
+
+def GetCwd : LibBuiltin<"unistd.h"> {
+ let Spellings = ["getcwd"];
+ let Attributes = [IgnoreSignature];
+ // char*(char*, size_t); size_t is target-specific
+ let Prototype = "";
+}
----------------
nuclearcat wrote:
Done
https://github.com/llvm/llvm-project/pull/224979
More information about the cfe-commits
mailing list