This is an archive of the discontinued LLVM Phabricator instance.

[Demangle] use std::string_view::data rather than &*std::string_view::begin
ClosedPublic

Authored by nickdesaulniers on Jul 10 2023, 12:15 PM.

Details

Summary

To fix expensive check builds that were failing when using MSVC's
std::string_view::iterator::operator*, I added a few expressions like
&*std::string_view::begin. @nico pointed out that this is literally the
same thing and more clearly expressed as std::string_view::data.

Link: https://github.com/llvm/llvm-project/issues/63740

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJul 10 2023, 12:15 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
nickdesaulniers requested review of this revision.Jul 10 2023, 12:15 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 10 2023, 12:15 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
nickdesaulniers edited the summary of this revision. (Show Details)Jul 10 2023, 12:16 PM
nickdesaulniers added a subscriber: thakis.
ldionne accepted this revision.Jul 10 2023, 12:36 PM

LGTM -- this would fail with libc++ bounded iterators as well, since you might end up dereferencing a past-the-end iterator in case the string is empty.

This revision is now accepted and ready to land.Jul 10 2023, 12:36 PM
philnik accepted this revision.Jul 10 2023, 12:37 PM

Thanks for the cleanup! LGTM with green CI.

MaskRay accepted this revision.Jul 10 2023, 12:56 PM
nickdesaulniers edited the summary of this revision. (Show Details)
  • rebase to rekick ci
nickdesaulniers edited the summary of this revision. (Show Details)Jul 10 2023, 1:40 PM
thakis added inline comments.Jul 11 2023, 9:07 AM
llvm/lib/Demangle/MicrosoftDemangle.cpp
2408

I think you no longer need the .empty() check once you use data(). If Name _is_ empty, then *Name.begin() is I think UB, but Name.data() isn't.

nickdesaulniers marked an inline comment as done.
nickdesaulniers edited the summary of this revision. (Show Details)
  • simplify NMangled calculation using size() rather than data()