[Lldb-commits] [PATCH] D151003: [Damangle] convert dlangDemangle to use std::string_view

Nick Desaulniers via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Jun 2 10:20:47 PDT 2023


nickdesaulniers marked an inline comment as done.
nickdesaulniers added inline comments.


================
Comment at: llvm/lib/Demangle/Demangle.cpp:49
 bool llvm::nonMicrosoftDemangle(const char *MangledName, std::string &Result) {
+  if (!MangledName)
+    return false;
----------------
nickdesaulniers wrote:
> MaskRay wrote:
> > Why is this change? The original contract is that `MangledName` must be non-null.
> https://fosstodon.org/@llvm/110397650834821908
> 
> It's insidious; implicitly constructing a `std::string_view` from a `char*` which is `nullptr` invokes a call to `strlen` upon construction, which segfaults on my system.  Therefor, all of the `nullptr` checks need to be hoisted into the callers or stated another way exist at the boundary of `char*` to `std::string_view` API boundaries (such as right here).
This is also why the `nullptr` input test case must be removed from llvm/unittests/Demangle/DLangDemangleTest.cpp below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151003



More information about the lldb-commits mailing list