[PATCH] D100246: [demangler] Use standard semantics for StringView::substr

Tomasz Miąsko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 10 08:54:18 PDT 2021


tmiasko created this revision.
Herald added a subscriber: mgorny.
tmiasko published this revision for review.
Herald added projects: libc++abi, LLVM.
Herald added subscribers: llvm-commits, libcxx-commits.
Herald added a reviewer: libc++abi.

The StringView::substr now accepts a substring starting position and its
length instead of previous non-standard `from` & `to` positions.

All uses of two argument StringView::substr are in MicrosoftDemangler
and have 0 as a starting position, so no changes are necessary.

This also fixes a bug where attempting to extract a suffix with substr
(a `to` position equal to size) would return a substring without the
last character.

Fixing the issue should not introduce observable changes in the
demangler, since as currently used, a second argument to
StringView::substr is either: 1) a result of a successful call to
StringView::find and so necessarily smaller than size., or 2) in the
case of Demangler::demangleCharLiteral potentially equal to size, but
with demangler expecting more data to follow later on and failing either
way.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100246

Files:
  libcxxabi/src/demangle/StringView.h
  llvm/include/llvm/Demangle/StringView.h
  llvm/unittests/Demangle/CMakeLists.txt
  llvm/unittests/Demangle/StringViewTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100246.336608.patch
Type: text/x-patch
Size: 3796 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210410/e83c6356/attachment.bin>


More information about the llvm-commits mailing list