[llvm-branch-commits] [clang] [clang] "modular_format" attribute for functions using format strings (PR #147431)

Aaron Ballman via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jul 16 05:23:24 PDT 2025


================
@@ -9427,3 +9427,29 @@ diagnostics with code like:
   __attribute__((nonstring)) char NotAStr[3] = "foo"; // Not diagnosed
   }];
 }
+
+def ModularFormatDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``modular_format`` attribute can be applied to a function that bears the
+``format`` attribute (or standard library functions) to indicate that the
+implementation is modular on the format string argument. When the format string
+for a given call is constant, the compiler may redirect the call to the symbol
+given as the first argument to the attribute (the modular implementation
+function).
+
+The second argument is a implementation name, and the remaining arguments are
+aspects of the format string for the compiler to report. If the compiler does
+not understand a aspect, it must summarily report that the format string has
+that aspect.
+
+The compiler reports an aspect by issing a relocation for the symbol
----------------
AaronBallman wrote:

```suggestion
The compiler reports an aspect by issuing a relocation for the symbol
```

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


More information about the llvm-branch-commits mailing list