This is an archive of the discontinued LLVM Phabricator instance.

[Demangle] refactor DLangDemangle to use std::string_view
ClosedPublic

Authored by nickdesaulniers on Jun 5 2023, 10:26 AM.

Details

Summary

Many existing methods of the D Language Demangler take a C style string
and return an adjusted pointer to the same object as the input string is
consumed.

Make it more obvious by changing the signatures to accept
std::string_view& when the input is modified vs a copy of a
std::string_view when the input is not.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2023, 10:26 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
nickdesaulniers requested review of this revision.Jun 5 2023, 10:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2023, 10:26 AM
efriedma added inline comments.Jun 5 2023, 10:41 AM
llvm/lib/Demangle/DLangDemangle.cpp
222

std::isalpha(Mangled.front()) is potentially out-of-bounds?

360

Indentation?

450–451

Mangled[0] is potentially out-of-bounds?

450–451

Maybe convert this char* to a string_view?

nickdesaulniers marked 4 inline comments as done.
  • format, check !empty before access to front, refactor NumPtr code
efriedma accepted this revision.Jun 5 2023, 1:14 PM

LGTM

llvm/lib/Demangle/DLangDemangle.cpp
213

This code isn't necessary? The while loop contains an equivalent guard.

This revision is now accepted and ready to land.Jun 5 2023, 1:14 PM
nickdesaulniers planned changes to this revision.Jun 5 2023, 2:20 PM
nickdesaulniers added inline comments.
llvm/lib/Demangle/DLangDemangle.cpp
55–56

TODO(@nickdesaulniers ): Fix all these comments up to reflect the changes.

nickdesaulniers marked an inline comment as done.
  • update comments, remove unnecessary check
This revision is now accepted and ready to land.Jun 5 2023, 2:27 PM
This revision was landed with ongoing or failed builds.Jun 5 2023, 2:39 PM
This revision was automatically updated to reflect the committed changes.