[PATCH] D111416: [Demangle] Add minimal support for D simple basic types

Luís Ferreira via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 11 18:22:45 PST 2022


ljmf00 added inline comments.


================
Comment at: llvm/lib/Demangle/DLangDemangle.cpp:275
+const char *Demangler::parseType(const char *Mangled) {
+  if (Mangled == nullptr || *Mangled == '\0')
+    return nullptr;
----------------
dblaikie wrote:
> Looks like this function is currently never called with a null parameter (the one call is inside an `if (Mangled != nullptr)` block). So this should probably be omitted, or replaced with an assertion.
> 
> Is the other condition (`== '\0'`) reachable/tested? (I guess it'd fall out naturally from the switch case below - so maybe that could be done instead and this if test/early return could be removed?)
Makes sense. I omitted the `nullptr` check, since this was contrarily tested on line 182 and this should never ever happen and an `assert` wouldn't benefit much as dereferencing will certainly happen right after anyway.

About the null terminator char check, I added a test for that.


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

https://reviews.llvm.org/D111416



More information about the llvm-commits mailing list