[libc-commits] [PATCH] D129950: [libc] Fix API for remove_{prefix, suffix}

Jeff Bailey via Phabricator via libc-commits libc-commits at lists.llvm.org
Sat Jul 16 19:43:18 PDT 2022


jeffbailey created this revision.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added projects: libc-project, All.
jeffbailey requested review of this revision.

The API in StringView.h for remove_prefix was incorrect and was returning a
new StringView rather than just altering the view.

As part of this, also removed some of the safety features.  The comment
correctly noted that the behaviour is undefined in some cases,
but the code and test cases checked for that.

One caller was relying on the old behaviour, so fixed it and added some
comments.

Tested:
check-libc
llvmlibc
libc-loader-tests


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129950

Files:
  libc/src/__support/CPP/StringView.h
  libc/src/stdlib/getenv.cpp
  libc/test/src/__support/CPP/stringview_test.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129950.445281.patch
Type: text/x-patch
Size: 3547 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20220717/0eae79b9/attachment.bin>


More information about the libc-commits mailing list