[mips] PR34083 - Wimplicit-fallthrough warning in MipsAsmParser.cpp
authorSimon Dardis <simon.dardis@imgtec.com>
Wed, 9 Aug 2017 10:47:52 +0000 (10:47 +0000)
committerSimon Dardis <simon.dardis@imgtec.com>
Wed, 9 Aug 2017 10:47:52 +0000 (10:47 +0000)
Assert that a binary expression is actually a binary expression,
rather than potientially incorrectly attempting to handle it as a
unary expression.

This resolves PR34083.

Thanks to Simonn Pilgrim for reporting the issue!

llvm-svn: 310460

llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp

index e12188e..8a5de01 100644 (file)
@@ -5439,12 +5439,13 @@ bool MipsAsmParser::isEvaluated(const MCExpr *Expr) {
     return true;
   case MCExpr::SymbolRef:
     return (cast<MCSymbolRefExpr>(Expr)->getKind() != MCSymbolRefExpr::VK_None);
-  case MCExpr::Binary:
-    if (const MCBinaryExpr *BE = dyn_cast<MCBinaryExpr>(Expr)) {
-      if (!isEvaluated(BE->getLHS()))
-        return false;
-      return isEvaluated(BE->getRHS());
-    }
+  case MCExpr::Binary: {
+    const MCBinaryExpr *BE = dyn_cast<MCBinaryExpr>(Expr);
+    assert(BE && "Binary expression is not a binary expression?");
+    if (!isEvaluated(BE->getLHS()))
+      return false;
+    return isEvaluated(BE->getRHS());
+  }
   case MCExpr::Unary:
     return isEvaluated(cast<MCUnaryExpr>(Expr)->getSubExpr());
   case MCExpr::Target: