diff --git a/libcxx/include/__bsd_locale_fallbacks.h b/libcxx/include/__bsd_locale_fallbacks.h --- a/libcxx/include/__bsd_locale_fallbacks.h +++ b/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); diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/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 diff --git a/libcxx/src/filesystem/filesystem_common.h b/libcxx/src/filesystem/filesystem_common.h --- a/libcxx/src/filesystem/filesystem_common.h +++ b/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 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);