[llvm-dev] Excessive use of LLVM_FALLTHROUGH?

Robinson, Paul via llvm-dev llvm-dev at lists.llvm.org
Wed Mar 1 14:59:14 PST 2017


I came across a weird-looking use of LLVM_FALLTHROUGH which I think is
completely spurious, but I figured I should check with the group mind
before ripping it out.  Basically, if you have multiple cases with no
code in between, you do *not* need LLVM_FALLTHROUGH, right?

  switch (Foo) {
  case Bar1:
    LLVM_FALLTHROUGH;  // not needed
  case Bar2:
    some code;
    return;
  case Bar3:
    LLVM_FALLTHROUGH; // not needed
  case Bar4:
    code without a break/return;
    LLVM_FALLTHROUGH; // <-- This one is needed.
  case Bar5:
    more code;
    break;
  default:
    llvm_unreachable("Foo with no Bar");
  }

So, can I take out all the ones marked "not needed" as an NFC cleanup?
Thanks,
--paulr

P.S. If you care, the specific example I tripped over is in
llvm/lib/CodeGen/AsmPrinter/DIE.cpp, DIEInteger::EmitValue().



More information about the llvm-dev mailing list