[llvm-branch-commits] [libcxx] 5410d0a - [libcxx] Silence -Wformat-nonliteral warnings in the Windows support code
Martin Storsjö via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Feb 10 12:47:40 PST 2022
Author: Martin Storsjö
Date: 2022-02-10T22:47:19+02:00
New Revision: 5410d0ac67ad0d64b973eab0f5bc106d75639790
URL: https://github.com/llvm/llvm-project/commit/5410d0ac67ad0d64b973eab0f5bc106d75639790
DIFF: https://github.com/llvm/llvm-project/commit/5410d0ac67ad0d64b973eab0f5bc106d75639790.diff
LOG: [libcxx] Silence -Wformat-nonliteral warnings in the Windows support code
This brings the mingw build back to zero build warnings as it was
at some earlier time.
Differential Revision: https://reviews.llvm.org/D119134
(cherry picked from commit 8cffea061afc556332a86fbf80ef5613db994974)
Added:
Modified:
libcxx/src/support/win32/locale_win32.cpp
libcxx/src/support/win32/support.cpp
Removed:
################################################################################
diff --git a/libcxx/src/support/win32/locale_win32.cpp b/libcxx/src/support/win32/locale_win32.cpp
index f10916875d42f..43e5c9a57227f 100644
--- a/libcxx/src/support/win32/locale_win32.cpp
+++ b/libcxx/src/support/win32/locale_win32.cpp
@@ -97,7 +97,10 @@ int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...)
ret, n, format, loc, ap);
#else
__libcpp_locale_guard __current(loc);
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
int result = vsnprintf( ret, n, format, ap );
+#pragma clang diagnostic pop
#endif
va_end(ap);
return result;
diff --git a/libcxx/src/support/win32/support.cpp b/libcxx/src/support/win32/support.cpp
index 115d975bbf9a6..6d4b371f3dc20 100644
--- a/libcxx/src/support/win32/support.cpp
+++ b/libcxx/src/support/win32/support.cpp
@@ -23,7 +23,10 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap )
// Query the count required.
va_list ap_copy;
va_copy(ap_copy, ap);
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
int count = vsnprintf( NULL, 0, format, ap_copy );
+#pragma clang diagnostic pop
va_end(ap_copy);
if (count < 0)
return count;
@@ -33,7 +36,10 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap )
return -1;
// If we haven't used exactly what was required, something is wrong.
// Maybe bug in vsnprintf. Report the error and return.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
if (vsnprintf(p, buffer_size, format, ap) != count) {
+#pragma clang diagnostic pop
free(p);
return -1;
}
More information about the llvm-branch-commits
mailing list