[clang] [clang] __builtin_os_log_format has incorrect PrintfFormat Attribute argument (PR #178320)
Ziqing Luo via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 27 15:49:20 PST 2026
https://github.com/ziqingluo-90 created https://github.com/llvm/llvm-project/pull/178320
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
>From d3ad7ac147634500c15c92ef9cf9b1bb0356da1f Mon Sep 17 00:00:00 2001
From: Ziqing Luo <ziqing_luo at apple.com>
Date: Tue, 27 Jan 2026 15:41:48 -0800
Subject: [PATCH] [clang] __builtin_os_log_format has incorrect PrintfFormat
Attribute argument
The incorrect format attribute argument causes false positive
-Wunsafe-buffer-usage-in-format-attr-call warnings.
The format string is the 2nd argument of __builtin_os_log_format, thus
has index 1 in 0-based indexing.
rdar://169043228
---
clang/include/clang/Basic/Builtins.td | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
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*, ...)";
}
More information about the cfe-commits
mailing list