[PATCH] D149675: [Demangle] convert itaniumDemangle and nonMicrosoftDemangle to use std::string_view

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 2 15:42:02 PDT 2023


efriedma added a comment.

Maybe it makes sense to revert D149104 <https://reviews.llvm.org/D149104> while you're fixing the various demanglers to correctly respect the input length?



================
Comment at: llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp:89-93
+  if (!Undecorated && DecoratedStr.substr(6) == "__imp_") {
     Prefix = "import thunk for ";
-    Undecorated = itaniumDemangle(DecoratedStr + 6, nullptr, nullptr, nullptr);
+    Undecorated =
+        itaniumDemangle(DecoratedStr.substr(6), nullptr, nullptr, nullptr);
   }
----------------
nickdesaulniers wrote:
> This needs a bounds check; otherwise a few lllvm-cxxfilt tests fail an assertion.
`DecoratedStr.substr(6) == "__imp_"` looks wrong.  Can we not just use `DecoratedStr.starts_with("__imp_")`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149675/new/

https://reviews.llvm.org/D149675



More information about the llvm-commits mailing list