This is an archive of the discontinued LLVM Phabricator instance.

[libc] Fix API for remove_{prefix, suffix}
ClosedPublic

Authored by jeffbailey on Jul 16 2022, 7:43 PM.

Details

Summary

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

Diff Detail

Event Timeline

jeffbailey created this revision.Jul 16 2022, 7:43 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 16 2022, 7:43 PM
jeffbailey requested review of this revision.Jul 16 2022, 7:43 PM
jeffbailey added a subscriber: rtenneti.

We found this bug while adapting the TZ variable parsing code to the cpp::StringView class.

gchatelet accepted this revision.Jul 18 2022, 5:06 AM
This revision is now accepted and ready to land.Jul 18 2022, 5:06 AM
This revision was automatically updated to reflect the committed changes.