From 74ccd062bdcd5f643b3ac3f974a6ece62c62e0a3 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 4 Jun 2015 07:40:16 +0000 Subject: [PATCH] [TableGen] Replace a couple if/else chains with a switch. NFC llvm-svn: 239023 --- llvm/include/llvm/TableGen/Record.h | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h index d451a2a..ecf9ea7 100644 --- a/llvm/include/llvm/TableGen/Record.h +++ b/llvm/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(); } } -- 2.7.4