[libc-commits] [libc] 7cbddd7 - [libc] Correctly add new files

Alex Brachet via libc-commits libc-commits at lists.llvm.org
Mon Apr 10 21:41:27 PDT 2023


Author: Alex Brachet
Date: 2023-04-11T04:41:14Z
New Revision: 7cbddd76b2d2955a5f751344076cba4db211b1dc

URL: https://github.com/llvm/llvm-project/commit/7cbddd76b2d2955a5f751344076cba4db211b1dc
DIFF: https://github.com/llvm/llvm-project/commit/7cbddd76b2d2955a5f751344076cba4db211b1dc.diff

LOG: [libc] Correctly add new files

Added: 
    libc/src/string/index.cpp
    libc/src/string/index.h
    libc/src/string/rindex.cpp
    libc/src/string/rindex.h
    libc/test/src/string/index_test.cpp
    libc/test/src/string/rindex_test.cpp

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/libc/src/string/index.cpp b/libc/src/string/index.cpp
new file mode 100644
index 0000000000000..0ea2f752e30c5
--- /dev/null
+++ b/libc/src/string/index.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of index -------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/string/index.h"
+
+#include "src/__support/common.h"
+#include "src/string/string_utils.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(char *, index, (const char *src, int c)) {
+  return internal::strchr_implementation(src, c);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/string/index.h b/libc/src/string/index.h
new file mode 100644
index 0000000000000..7b246109d46f9
--- /dev/null
+++ b/libc/src/string/index.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for index -------------------------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_STRING_INDEX_H
+#define LLVM_LIBC_SRC_STRING_INDEX_H
+
+namespace __llvm_libc {
+
+char *index(const char *src, int c);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_STRING_INDEX_H

diff  --git a/libc/src/string/rindex.cpp b/libc/src/string/rindex.cpp
new file mode 100644
index 0000000000000..520a4dbeda20f
--- /dev/null
+++ b/libc/src/string/rindex.cpp
@@ -0,0 +1,20 @@
+//===-- Implementation of rindex ------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/string/rindex.h"
+
+#include "src/__support/common.h"
+#include "src/string/string_utils.h"
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(char *, rindex, (const char *src, int c)) {
+  return internal::strrchr_implementation(src, c);
+}
+
+} // namespace __llvm_libc

diff  --git a/libc/src/string/rindex.h b/libc/src/string/rindex.h
new file mode 100644
index 0000000000000..976d6bac93131
--- /dev/null
+++ b/libc/src/string/rindex.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for rindex ------------------------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_STRING_RINDEX_H
+#define LLVM_LIBC_SRC_STRING_RINDEX_H
+
+namespace __llvm_libc {
+
+char *rindex(const char *src, int c);
+
+} // namespace __llvm_libc
+
+#endif // LLVM_LIBC_SRC_STRING_RINDEX_H

diff  --git a/libc/test/src/string/index_test.cpp b/libc/test/src/string/index_test.cpp
new file mode 100644
index 0000000000000..22202f0fc8346
--- /dev/null
+++ b/libc/test/src/string/index_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for index -----------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "StrchrTest.h"
+
+#include "src/string/index.h"
+#include "test/UnitTest/Test.h"
+
+STRCHR_TEST(Index, __llvm_libc::index)

diff  --git a/libc/test/src/string/rindex_test.cpp b/libc/test/src/string/rindex_test.cpp
new file mode 100644
index 0000000000000..1e5969653d5e7
--- /dev/null
+++ b/libc/test/src/string/rindex_test.cpp
@@ -0,0 +1,14 @@
+//===-- Unittests for rindex ----------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "StrchrTest.h"
+
+#include "src/string/rindex.h"
+#include "test/UnitTest/Test.h"
+
+STRRCHR_TEST(Rindex, __llvm_libc::rindex)


        


More information about the libc-commits mailing list