]> granicus.if.org Git - llvm/commitdiff
HexagonAsmParser::ParseDirectiveFalign - silence static analyzer dyn_cast<MCConstantE...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 26 Sep 2019 10:35:19 +0000 (10:35 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 26 Sep 2019 10:35:19 +0000 (10:35 +0000)
The static analyzer is warning about a potential null dereference, but we should be able to use cast<MCConstantExpr> directly and if not assert will fire for us.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372956 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp

index 0881bf841f90121ddd5b4e5310a0b774c5481178..590c4a2eb69d4476cedcdde28ebb297e57d53cf4 100644 (file)
@@ -702,7 +702,7 @@ bool HexagonAsmParser::ParseDirectiveFalign(unsigned Size, SMLoc L) {
     // Make sure we have a number (false is returned if expression is a number)
     if (!getParser().parseExpression(Value)) {
       // Make sure this is a number that is in range
-      const MCConstantExpr *MCE = dyn_cast<MCConstantExpr>(Value);
+      auto *MCE = cast<MCConstantExpr>(Value);
       uint64_t IntValue = MCE->getValue();
       if (!isUIntN(Size, IntValue) && !isIntN(Size, IntValue))
         return Error(ExprLoc, "literal value out of range (256) for falign");