[clang] [clang] __builtin_os_log_format has incorrect PrintfFormat Attribute argument (PR #178320)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 27 15:49:53 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Ziqing Luo (ziqingluo-90)

<details>
<summary>Changes</summary>

The format string is the 2nd argument of __builtin_os_log_format, thus has index 1 instead of 0 in 0-based indexing.
The incorrect format attribute argument causes false positive -Wunsafe-buffer-usage-in-format-attr-call warnings.

rdar://169043228

---
Full diff: https://github.com/llvm/llvm-project/pull/178320.diff


1 Files Affected:

- (modified) clang/include/clang/Basic/Builtins.td (+1-2) 


``````````diff
diff --git a/clang/include/clang/Basic/Builtins.td b/clang/include/clang/Basic/Builtins.td
index dcf07d659cb15..1bfee45feb84f 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4970,8 +4970,7 @@ def OSLogFormatBufferSize : Builtin {
 
 def OSLogFormat : Builtin {
   let Spellings = ["__builtin_os_log_format"];
-  // FIXME: The printf attribute looks suspiciously like it should be argument #1.
-  let Attributes = [PrintfFormat<0>, NoThrow, CustomTypeChecking];
+  let Attributes = [PrintfFormat<1>, NoThrow, CustomTypeChecking];
   let Prototype = "void*(void*, char const*, ...)";
 }
 

``````````

</details>


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


More information about the cfe-commits mailing list