[libcxx-commits] [PATCH] D102414: [libc++] Improve make_string test support.
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu May 13 09:27:48 PDT 2021
Mordante created this revision.
Mordante added a reviewer: cjdb.
Mordante requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
Adds MAKE_CSTRING and makes the operators of `MultiStringType` `constexpr`.
The code is copied from D96664 <https://reviews.llvm.org/D96664> so it can be used in D80895 <https://reviews.llvm.org/D80895>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D102414
Files:
libcxx/test/support/make_string.h
Index: libcxx/test/support/make_string.h
===================================================================
--- libcxx/test/support/make_string.h
+++ libcxx/test/support/make_string.h
@@ -39,13 +39,13 @@
const char16_t* u16;
const char32_t* u32;
- operator const char*() const { return s; }
- operator const wchar_t*() const { return w; }
+ constexpr operator const char*() const { return s; }
+ constexpr operator const wchar_t*() const { return w; }
#if TEST_STD_VER > 17 && defined(__cpp_char8_t)
- operator const char8_t*() const { return u8; }
+ constexpr operator const char8_t*() const { return u8; }
#endif
- operator const char16_t*() const { return u16; }
- operator const char32_t*() const { return u32; }
+ constexpr operator const char16_t*() const { return u16; }
+ constexpr operator const char32_t*() const { return u32; }
};
// Helper to convert a const char* string to a basic_string<CharT>.
@@ -56,4 +56,10 @@
static_cast<const CharT*>(MultiStringType MKSTR(Str)) \
}
+// Helper to convert a const char* string to a const CharT*.
+// This helper is used in unit tests to make them generic. The input should be
+// valid ASCII which means the input is also valid UTF-8.
+#define MAKE_CSTRING(CharT, Str) \
+ static_cast<const CharT*>(MultiStringType MKSTR(Str))
+
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102414.345182.patch
Type: text/x-patch
Size: 1393 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210513/a7f46fd7/attachment.bin>
More information about the libcxx-commits
mailing list