diff options
author | Timm Baeder <tbaeder@redhat.com> | 2025-03-24 12:28:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-24 12:28:23 +0100 |
commit | c7f14f601f36f8fdabb9182e253add18a471308f (patch) | |
tree | 10ef58273c42b6c8a039f8bba1acfc84cbda6876 /clang/test/AST/ByteCode/builtin-functions.cpp | |
parent | ad9630d5ee657dd24015afe70016def0c41061fb (diff) | |
download | llvm-c7f14f601f36f8fdabb9182e253add18a471308f.zip llvm-c7f14f601f36f8fdabb9182e253add18a471308f.tar.gz llvm-c7f14f601f36f8fdabb9182e253add18a471308f.tar.bz2 |
[clang][bytecode] Implement __builtin_wcschr (#132708)
This is already almost implemented, just need to enable support for it.
Diffstat (limited to 'clang/test/AST/ByteCode/builtin-functions.cpp')
-rw-r--r-- | clang/test/AST/ByteCode/builtin-functions.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp b/clang/test/AST/ByteCode/builtin-functions.cpp index 13a34f7..c3ea158 100644 --- a/clang/test/AST/ByteCode/builtin-functions.cpp +++ b/clang/test/AST/ByteCode/builtin-functions.cpp @@ -21,6 +21,7 @@ extern "C" { extern void *memchr(const void *s, int c, size_t n); extern char *strchr(const char *s, int c); extern wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n); + extern wchar_t *wcschr(const wchar_t *s, wchar_t c); } namespace strcmp { @@ -1511,4 +1512,24 @@ namespace WMemChr { constexpr wchar_t kStr2[] = {L'f', L'o', L'\xffff', L'o'}; static_assert(__builtin_wmemchr(kStr2, L'\xffff', 4) == kStr2 + 2); + + + static_assert(__builtin_wcschr(kStr, L'a') == kStr); + static_assert(__builtin_wcschr(kStr, L'b') == kStr + 1); + static_assert(__builtin_wcschr(kStr, L'c') == kStr + 2); + static_assert(__builtin_wcschr(kStr, L'd') == nullptr); + static_assert(__builtin_wcschr(kStr, L'e') == nullptr); + static_assert(__builtin_wcschr(kStr, L'\0') == kStr + 5); + static_assert(__builtin_wcschr(kStr, L'a' + 256) == nullptr); + static_assert(__builtin_wcschr(kStr, L'a' - 256) == nullptr); + static_assert(__builtin_wcschr(kStr, L'\xffff') == kStr + 4); + static_assert(__builtin_wcschr(kFoo, L'o') == kFoo + 1); + static_assert(__builtin_wcschr(kFoo, L'x') == nullptr); // both-error {{not an integral constant}} \ + // both-note {{dereferenced one-past-the-end}} + static_assert(__builtin_wcschr(nullptr, L'x') == nullptr); // both-error {{not an integral constant}} \ + // both-note {{dereferenced null}} + + + constexpr bool c = !wcschr(L"hello", L'h'); // both-error {{constant expression}} \ + // both-note {{non-constexpr function 'wcschr' cannot be used in a constant expression}} } |