Don't dereference from a dyn_cast<>. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 14 Sep 2020 12:04:44 +0000 (13:04 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 14 Sep 2020 12:05:17 +0000 (13:05 +0100)
Use cast<> instead which will assert if it fails and not just return null.

Fixes clang static analyzer warning.

llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp

index 230bc7a..0abe42d 100644 (file)
@@ -166,13 +166,13 @@ public:
     assert(N == 1 && "Invalid number of operands!");
     // The operand is actually a imm8, but we have its bitwise
     // negation in the assembly source, so twiddle it here.
-    const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getImm());
+    const auto *CE = cast<MCConstantExpr>(getImm());
     Inst.addOperand(MCOperand::createImm(~(uint8_t)CE->getValue()));
   }
 
   bool isImmCom8() const {
     if (!isImm()) return false;
-    const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getImm());
+    const auto *CE = dyn_cast<MCConstantExpr>(getImm());
     if (!CE) return false;
     int64_t Value = CE->getValue();
     return isUInt<8>(Value);