[libcxx-commits] [PATCH] D113876: [libc++] Add missing __format__ attributes
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Nov 16 12:24:48 PST 2021
ldionne updated this revision to Diff 387734.
ldionne retitled this revision from "[libc++] Silence -Wformat-nonliteral warnings in __bsd_locale_fallbacks.h" to "[libc++] Add missing __format__ attributes".
ldionne edited the summary of this revision.
ldionne added a comment.
Update with __format__ attributes instead of pragmas to turn off the warning.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113876/new/
https://reviews.llvm.org/D113876
Files:
libcxx/include/__bsd_locale_fallbacks.h
libcxx/include/__config
libcxx/src/filesystem/filesystem_common.h
Index: libcxx/src/filesystem/filesystem_common.h
===================================================================
--- libcxx/src/filesystem/filesystem_common.h
+++ libcxx/src/filesystem/filesystem_common.h
@@ -60,7 +60,7 @@
namespace {
-static _LIBCPP_FORMAT_PRINTF(1, 0) string
+static _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 0) string
format_string_impl(const char* msg, va_list ap) {
array<char, 256> buf;
@@ -84,7 +84,7 @@
return result;
}
-static _LIBCPP_FORMAT_PRINTF(1, 2) string
+static _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) string
format_string(const char* msg, ...) {
string ret;
va_list ap;
@@ -172,7 +172,7 @@
_LIBCPP_UNREACHABLE();
}
- _LIBCPP_FORMAT_PRINTF(3, 0)
+ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 0)
void report_impl(const error_code& ec, const char* msg, va_list ap) const {
if (ec_) {
*ec_ = ec;
@@ -191,7 +191,7 @@
_LIBCPP_UNREACHABLE();
}
- _LIBCPP_FORMAT_PRINTF(3, 4)
+ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4)
T report(const error_code& ec, const char* msg, ...) const {
va_list ap;
va_start(ap, msg);
@@ -213,7 +213,7 @@
return report(make_error_code(err));
}
- _LIBCPP_FORMAT_PRINTF(3, 4)
+ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4)
T report(errc const& err, const char* msg, ...) const {
va_list ap;
va_start(ap, msg);
Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -1352,10 +1352,11 @@
#endif
#if defined(__GNUC__) || defined(__clang__)
-#define _LIBCPP_FORMAT_PRINTF(a, b) \
- __attribute__((__format__(__printf__, a, b)))
+ // The attribute uses 1-based indices.
+# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
+ __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
#else
-#define _LIBCPP_FORMAT_PRINTF(a, b)
+# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */
#endif
#endif // __cplusplus
Index: libcxx/include/__bsd_locale_fallbacks.h
===================================================================
--- libcxx/include/__bsd_locale_fallbacks.h
+++ libcxx/include/__bsd_locale_fallbacks.h
@@ -108,7 +108,7 @@
}
#endif
-inline
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 4, 5)
int __libcpp_snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) {
va_list __va;
va_start(__va, __format);
@@ -118,7 +118,7 @@
return __res;
}
-inline
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4)
int __libcpp_asprintf_l(char **__s, locale_t __l, const char *__format, ...) {
va_list __va;
va_start(__va, __format);
@@ -128,7 +128,7 @@
return __res;
}
-inline
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATTRIBUTE_FORMAT(__scanf__, 3, 4)
int __libcpp_sscanf_l(const char *__s, locale_t __l, const char *__format, ...) {
va_list __va;
va_start(__va, __format);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113876.387734.patch
Type: text/x-patch
Size: 3103 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211116/77a1b2fd/attachment-0001.bin>
More information about the libcxx-commits
mailing list