This is an archive of the discontinued LLVM Phabricator instance.

reland: [Demangle] make llvm::demangle take std::string_view rather than const std::string&
ClosedPublic

Authored by nickdesaulniers on Apr 24 2023, 3:55 PM.

Details

Summary

As suggested by @erichkeane in
https://reviews.llvm.org/D141451#inline-1429549

There's potential for a lot more cleanups around these APIs. This is
just a start.

Callers need to be more careful about sub-expressions producing strings
that don't outlast the expression using llvm::demangle. Add a
release note.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptApr 24 2023, 3:55 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
nickdesaulniers requested review of this revision.Apr 24 2023, 3:55 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 24 2023, 3:55 PM

oh, I can clean up all of the callers of llvm::demangle now, too. Did I do that last week, as a separate patch? Let me see...

MaskRay added inline comments.Apr 24 2023, 4:27 PM
llvm/lib/Demangle/Demangle.cpp
39

LLVM Coding Style prefers static to an anonymous namespace.

nickdesaulniers marked an inline comment as done.
nickdesaulniers retitled this revision from [Demangle] use moar std::string_view to [Demangle] make llvm::demangle take std::string_view rather than const std::string&.
nickdesaulniers edited the summary of this revision. (Show Details)
  • prefer static linkage to anonymous namespace
  • add release notes
  • update most callsites
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript
MaskRay added inline comments.Apr 24 2023, 4:49 PM
lld/ELF/Symbols.cpp
50 ↗(On Diff #516580)

return demangle(symName.str());

perhaps return demangle(symName); works as well?

lld/COFF/Symbols.cpp
43 ↗(On Diff #516580)

probably should just be return prefix + demangled;

lld/ELF/Symbols.cpp
50 ↗(On Diff #516580)

perhaps return demangle(symName); works as well?

I saw test failures with that change. I can keep it as is; wasn't sure if it's worth making this more obvious...

llvm/docs/ReleaseNotes.rst
291 ↗(On Diff #516580)

expression

nickdesaulniers marked an inline comment as done.
  • fix typos
  • simplify maybeDemangleSymbol in lld COFF
  • restore maybeDemangleSymbol

bumping for review

MaskRay accepted this revision.May 1 2023, 6:38 PM

Looks great!

llvm/docs/ReleaseNotes.rst
289 ↗(On Diff #516582)

The text wrapping appears to use a very small set textwidth (neovim)?

This revision is now accepted and ready to land.May 1 2023, 6:38 PM
nickdesaulniers marked an inline comment as done.May 2 2023, 11:09 AM

Thanks for the review!

llvm/docs/ReleaseNotes.rst
289 ↗(On Diff #516582)

No, just me manually correcting it; otherwise we have a line ending like <backtick><backtic>const
which looks odd to me. I don't think it matters for rendering restructured text either way.

This revision was landed with ongoing or failed builds.May 2 2023, 11:20 AM
This revision was automatically updated to reflect the committed changes.
nickdesaulniers marked an inline comment as done.

Looks like this is causing a regression in lld/test/wasm/why-extract.s when -DLLVM_ENABLE_EXPENSIVE_CHECKS=ON is enabled. I'm looking into it and hoping to fix forward by EOD.

Looks like this is causing a regression in lld/test/wasm/why-extract.s when -DLLVM_ENABLE_EXPENSIVE_CHECKS=ON is enabled. I'm looking into it and hoping to fix forward by EOD.

Fixup: https://reviews.llvm.org/D149675

nickdesaulniers reopened this revision.May 2 2023, 3:57 PM
This revision is now accepted and ready to land.May 2 2023, 3:57 PM
nickdesaulniers planned changes to this revision.May 2 2023, 3:57 PM
nickdesaulniers retitled this revision from [Demangle] make llvm::demangle take std::string_view rather than const std::string& to reland: [Demangle] make llvm::demangle take std::string_view rather than const std::string&.
nickdesaulniers edited the summary of this revision. (Show Details)
  • rebase
This revision is now accepted and ready to land.Jun 5 2023, 3:19 PM