[libc-commits] [libc] [libc] Implement vswprintf entrypoint. (PR #243606)

Alexey Samsonov via libc-commits libc-commits at lists.llvm.org
Tue Nov 17 12:58:00 PST 2026


================
@@ -0,0 +1,130 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Unittests for vswprintf.
+///
+//===----------------------------------------------------------------------===//
+
+// These tests are shortened copies of the non-v variants of the swprintf
+// functions. This is because these functions are identical in every way except
+// for how the varargs are passed.
+
+#include "hdr/types/size_t.h"
+#include "hdr/types/wchar_t.h"
+#include "src/wchar/vswprintf.h"
+#include "test/UnitTest/Test.h"
+
+#include <stdarg.h>
+
+int call_vswprintf(wchar_t *__restrict buffer, size_t bufsz,
+                   const wchar_t *__restrict format, ...) {
+  va_list vlist;
+  va_start(vlist, format);
+  int ret = LIBC_NAMESPACE::vswprintf(buffer, bufsz, format, vlist);
+  va_end(vlist);
+  return ret;
+}
+
+TEST(LlvmLibcVSWPrintfTest, SimpleNoConv) {
----------------
vonosmas wrote:

Since vswprintf is expected to set errno, I'd make these test cases use ErrnoCheckingTest and validate at least 1-2 error cases.

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


More information about the libc-commits mailing list