================
@@ -1897,7 +1897,34 @@ def CrossTURemarks : DiagGroup<"ctu-remarks">;
def CTADMaybeUnsupported : DiagGroup<"ctad-maybe-unsupported">;
-def FortifySource : DiagGroup<"fortify-source", [FormatOverflow,
FormatTruncation]>;
+def FortifySource : DiagGroup<"fortify-source", [FormatOverflow,
FormatTruncation]> {
+ code Documentation = [{
+Warns at compile time when calls to standard C library or POSIX functions have
+provably out-of-bounds destination buffers or invalid constant arguments,
+modeled after `_FORTIFY_SOURCE` compile-time checks.
+
+This diagnostic group checks:
+
+1. **Destination buffer overflows and format truncation**: Diagnoses when a
+ write operation will always overflow the destination buffer, when an
+ explicit size argument exceeds the known size of the destination buffer, or
+ when formatted output will always be truncated:
+ - `<string.h>` / `<strings.h>`: `memcpy`, `memmove`, `memset`, `mempcpy`,
+ `bcopy`, `bzero`, `strcpy`, `stpcpy`, `strcat`, `strncpy`, `stpncpy`,
+ `strncat`, `strlcpy`, `strlcat` (and their `__builtin_` variants).
+ - `<stdio.h>`: `sprintf`, `snprintf`, `vsnprintf`, `scanf`, `fscanf`,
+ `sscanf` (also controlled by {ref}`-Wformat-overflow` and
+ {ref}`-Wformat-truncation`).
+
+2. **Invalid constant arguments**:
+ - `<sys/stat.h>`: `umask` when called with constant mode bits outside `0777`
+ that are silently ignored.
+
+Note: Related bounds checks for `__builtin___*_chk` functions and source buffer
----------------
nickdesaulniers wrote:
Most, not all, right?
```suggestion
Note: Related bounds checks for most `__builtin___*_chk` functions and source
buffer
```
https://github.com/llvm/llvm-project/pull/224111
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits