Reland "[libc] Add {,r}index"

Differential Revision: https://reviews.llvm.org/D147464
This commit is contained in:
Alex Brachet 2023-04-11 04:30:50 +00:00
parent 0beeadf203
commit 9c7a370505
7 changed files with 66 additions and 6 deletions

View File

@ -33,6 +33,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.bcmp
libc.src.string.bcopy
libc.src.string.bzero
libc.src.string.index
libc.src.string.memccpy
libc.src.string.memchr
libc.src.string.memcmp
@ -41,6 +42,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.mempcpy
libc.src.string.memrchr
libc.src.string.memset
libc.src.string.rindex
libc.src.string.stpcpy
libc.src.string.stpncpy
libc.src.string.strcasecmp

View File

@ -24,6 +24,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.bcmp
libc.src.string.bcopy
libc.src.string.bzero
libc.src.string.index
libc.src.string.memccpy
libc.src.string.memchr
libc.src.string.memcmp
@ -32,6 +33,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.mempcpy
libc.src.string.memrchr
libc.src.string.memset
libc.src.string.rindex
libc.src.string.stpcpy
libc.src.string.stpncpy
libc.src.string.strcasecmp

View File

@ -33,6 +33,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.bcmp
libc.src.string.bcopy
libc.src.string.bzero
libc.src.string.index
libc.src.string.memccpy
libc.src.string.memchr
libc.src.string.memcmp
@ -41,6 +42,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.mempcpy
libc.src.string.memrchr
libc.src.string.memset
libc.src.string.rindex
libc.src.string.stpcpy
libc.src.string.stpncpy
libc.src.string.strcasecmp

View File

@ -33,6 +33,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.bcmp
libc.src.string.bcopy
libc.src.string.bzero
libc.src.string.index
libc.src.string.memccpy
libc.src.string.memchr
libc.src.string.memcmp
@ -41,6 +42,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.mempcpy
libc.src.string.memrchr
libc.src.string.memset
libc.src.string.rindex
libc.src.string.stpcpy
libc.src.string.stpncpy
libc.src.string.strcasecmp

View File

@ -39,6 +39,16 @@ def BsdExtensions : StandardSpec<"BSDExtensions"> {
RetValSpec<IntType>,
[ArgSpec<ConstCharPtr>, ArgSpec<ConstCharPtr>, ArgSpec<SizeTType>]
>,
FunctionSpec<
"index",
RetValSpec<CharPtr>,
[ArgSpec<ConstCharPtr>, ArgSpec<IntType>]
>,
FunctionSpec<
"rindex",
RetValSpec<CharPtr>,
[ArgSpec<ConstCharPtr>, ArgSpec<IntType>]
>,
]
>;

View File

@ -31,6 +31,16 @@ add_entrypoint_object(
bcopy.h
)
add_entrypoint_object(
index
SRCS
index.cpp
HDRS
index.h
DEPENDS
.string_utils
)
add_entrypoint_object(
memccpy
SRCS
@ -67,6 +77,16 @@ add_entrypoint_object(
memrchr.h
)
add_entrypoint_object(
rindex
SRCS
rindex.cpp
HDRS
rindex.h
DEPENDS
.string_utils
)
add_entrypoint_object(
stpcpy
SRCS

View File

@ -14,6 +14,23 @@ add_libc_unittest(
LibcMemoryHelpers
)
add_header_library(
strchr_test_support
HDRS
StrchrTest.h
)
add_libc_unittest(
index_test
SUITE
libc_string_unittests
SRCS
index_test.cpp
DEPENDS
libc.src.string.index
.strchr_test_support
)
add_libc_unittest(
memccpy_test
SUITE
@ -54,6 +71,17 @@ add_libc_unittest(
libc.src.string.memrchr
)
add_libc_unittest(
rindex_test
SUITE
libc_string_unittests
SRCS
rindex_test.cpp
DEPENDS
libc.src.string.rindex
.strchr_test_support
)
add_libc_unittest(
stpcpy_test
SUITE
@ -84,12 +112,6 @@ add_libc_unittest(
libc.src.string.strcat
)
add_header_library(
strchr_test_support
HDRS
StrchrTest.h
)
add_libc_unittest(
strchr_test
SUITE