From: Craig Topper Date: Thu, 4 Jun 2015 07:40:16 +0000 (+0000) Subject: [TableGen] Replace a couple if/else chains with a switch. NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=71bb0e10c4efb54531fef78c662ea5228ef730c8;p=llvm [TableGen] Replace a couple if/else chains with a switch. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239023 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/TableGen/Record.h b/include/llvm/TableGen/Record.h index d451a2a04f6..ecf9ea7b70a 100644 --- a/include/llvm/TableGen/Record.h +++ b/include/llvm/TableGen/Record.h @@ -752,11 +752,10 @@ public: int getNumOperands() const override { return 2; } Init *getOperand(int i) const override { - assert((i == 0 || i == 1) && "Invalid operand id for binary operator"); - if (i == 0) { - return getLHS(); - } else { - return getRHS(); + switch (i) { + default: llvm_unreachable("Invalid operand id for binary operator"); + case 0: return getLHS(); + case 1: return getRHS(); } } @@ -808,14 +807,11 @@ public: int getNumOperands() const override { return 3; } Init *getOperand(int i) const override { - assert((i == 0 || i == 1 || i == 2) && - "Invalid operand id for ternary operator"); - if (i == 0) { - return getLHS(); - } else if (i == 1) { - return getMHS(); - } else { - return getRHS(); + switch (i) { + default: llvm_unreachable("Invalid operand id for ternary operator"); + case 0: return getLHS(); + case 1: return getMHS(); + case 2: return getRHS(); } }