[PATCH] D87697: Do not construct std::string from nullptr
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 4 18:18:52 PST 2020
dblaikie added a comment.
In D87697#2295870 <https://reviews.llvm.org/D87697#2295870>, @mclow.lists wrote:
> I would rather see:
>
> llvm_unreachable("unexpected type");
> return ""; // or string()
>
> i.e, keep the call to unreachable.
I'd split the difference and keep the unreachable but drop the return - llvm_unreachable is annotated noreturn and all the compilers we use for LLVM are OK with/don't warn on: "non_void f1() { llvm_unreachable(...); }"
As for the possibility of relying on a switch with a default, where all cases and the default return or call a no-return function. I'd be OK with that, if it works for all the compilers LLVM supports - if there's prior art/examples of this in the LLVM codebase, that'd be adequate for me.
& yeah, I'd be OK with @mclow.lists 's suggestion to move the default to the end and just have it break, keeping a singular unreachable (& though I'd favor fairly strongly not having a return after that) outside the switch.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D87697/new/
https://reviews.llvm.org/D87697
More information about the llvm-commits
mailing list