This is an archive of the discontinued LLVM Phabricator instance.

[Demangle] replace std::string_view::substr which may throw
ClosedPublic

Authored by nickdesaulniers on Apr 21 2023, 2:01 PM.

Details

Summary

llvm/Demangle copies the implementation from libcxxabi/src/demangle/.
libcxxabi/ cannot use potentially-throwing std::string_view::substr, so
change llvm/Demangle to avoid these function calls.

I ran into linkage failures stemming from the usage of
std::string_view::substr. substr does a bounds check and may throw.

Fixes: f198e0b594aa ("[StringView] remove dropFront")

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2023, 2:01 PM
nickdesaulniers requested review of this revision.Apr 21 2023, 2:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2023, 2:01 PM
MaskRay accepted this revision.Apr 21 2023, 2:08 PM

The "upstream" source of this file is in libcxxabi/src/demangle/. As I ...

The paragraph felt a bit confusing before I clicked and read D148566.

You may say that libcxxabi/src/demangle/ copies the implementation from llvm/Demangle. libcxxabi/ cannot use potentially-throwing std::string_view::substr, so we change llvm/Demangle to avoid these function calls.
Then in a separate graph add evidence how libcxxabi cannot use potentially-throwing functions ("I ran into linkage failures stemming from the usage of std::string_view::substr. substr does a bounds check and may throw.")

This revision is now accepted and ready to land.Apr 21 2023, 2:08 PM
nickdesaulniers edited the summary of this revision. (Show Details)
  • improve commit message with @MaskRay's wording
nickdesaulniers edited the summary of this revision. (Show Details)
  • update which copy is the upstream in commit message
This revision was landed with ongoing or failed builds.Apr 21 2023, 3:57 PM
This revision was automatically updated to reflect the committed changes.