This is an archive of the discontinued LLVM Phabricator instance.

[demangler] Use standard semantics for StringView::substr
ClosedPublic

Authored by tmiasko on Apr 10 2021, 6:15 AM.

Details

Summary

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.

Diff Detail

Event Timeline

tmiasko created this revision.Apr 10 2021, 6:15 AM
tmiasko published this revision for review.Apr 10 2021, 8:54 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 10 2021, 8:54 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne accepted this revision.Apr 12 2021, 9:20 AM
ldionne added a reviewer: erik.pilkington.
ldionne added a subscriber: ldionne.

This LGTM at a glance, but I'd like Erik to give his thumbs up.

erik.pilkington accepted this revision.Apr 12 2021, 9:29 AM

LGTM as well, thanks!

This revision is now accepted and ready to land.Apr 12 2021, 9:29 AM

Could you commit this for me? Thank you.

Ping. I don't have commit access.

Can you provide your name and email address so we can commit the patch on your behalf?

Tomasz Miąsko <tomasz.miasko@gmail.com>

This revision was automatically updated to reflect the committed changes.