[llvm] r310460 - [mips] PR34083 - Wimplicit-fallthrough warning in MipsAsmParser.cpp

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 14 13:40:36 PDT 2017


Maybe use 'cast' instead of 'dyn_cast' - then there's no need for the
assert? (since it's built into 'cast')

On Wed, Aug 9, 2017 at 3:48 AM Simon Dardis via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: sdardis
> Date: Wed Aug  9 03:47:52 2017
> New Revision: 310460
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310460&view=rev
> Log:
> [mips] PR34083 - Wimplicit-fallthrough warning in MipsAsmParser.cpp
>
> 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!
>
> Modified:
>     llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
>
> Modified: llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp?rev=310460&r1=310459&r2=310460&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (original)
> +++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp Wed Aug  9
> 03:47:52 2017
> @@ -5439,12 +5439,13 @@ bool MipsAsmParser::isEvaluated(const MC
>      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:
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170814/2053a8c5/attachment.html>


More information about the llvm-commits mailing list