[libc-commits] [PATCH] D77279: [libc] Add strlen implementation.

Alex Brachet via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Apr 1 19:04:51 PDT 2020


abrachet added inline comments.


================
Comment at: libc/src/string/strcpy.cpp:17
 
 char *LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {
   return reinterpret_cast<char *>(
----------------
We could make these `__restrict` while we're here but I think it there might be no benefit given we just call memcpy.


================
Comment at: libc/src/string/strlen.cpp:18
+  const char *end = src;
+  while (*end != '\0') {
+    end++;
----------------
Brackets not common for single statement loops.


================
Comment at: libc/src/string/strlen.h:1
-//===-------------------- Implementation of strcpy -----------------------===//
+//===----------------- Implementation header for strlen -------------------===//
 //
----------------
We could add the `-*- C++ -*-`


================
Comment at: libc/test/src/string/strlen_test.cpp:16
+  size_t result = __llvm_libc::strlen(empty);
+  ASSERT_EQ((size_t)0, result);
+}
----------------
Maybe `0UL` and `12UL` whichever you think looks better.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77279/new/

https://reviews.llvm.org/D77279





More information about the libc-commits mailing list