[PATCH] D67867: [libc] Add few docs and implementation of strcpy and strcat.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 08:57:34 PDT 2019


MaskRay added a comment.

In D67867#1683099 <https://reviews.llvm.org/D67867#1683099>, @sivachandra wrote:

> In D67867#1682894 <https://reviews.llvm.org/D67867#1682894>, @jyknight wrote:
>
> > I think one directory per function is going to be annoying, not helpful. Most libc functions are expressible as a single function of less than 100 LOC. I'd suggest, instead, to have e.g. `src/stdlib/strcpy.cc`, implementing the strcpy function. It seems like a good rule that every file implements one public function. If additional files are needed for implementation clarity, I'd suggest to put such helper code into something like `src/stdlib/internal/strcpy_internal.cpp` (obviously not _actually_ for strcpy)
>
>
> My choice here is driven by my preference to keep tests co-located with the implementation. Since we are in general going to have different kinds of testing like unit-testing, differential testing, fuzz-testing, I have chosen to put implementations of individual functions in their own directories. This way, the tests (which will span multiple files) will all be in a single directory and avoid clutter in the higher level directory. In the rare occasion that implementation also spans multiple files, all the implementation files will also live together.


Some tests will involve several functions from a header, e.g. flockfile+ftrylock+funlockfile. Where will you place the test, under flockfile/, or funlockfile/ ?

I prefer jyknight's proposed hierarchy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67867





More information about the llvm-commits mailing list