[llvm] 7109fc9 - Don't dereference from a dyn_cast<>. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 05:12:27 PDT 2020


Author: Simon Pilgrim
Date: 2020-09-14T13:05:17+01:00
New Revision: 7109fc9e42e6b9a56497dcc6a25228d818af4f38

URL: https://github.com/llvm/llvm-project/commit/7109fc9e42e6b9a56497dcc6a25228d818af4f38
DIFF: https://github.com/llvm/llvm-project/commit/7109fc9e42e6b9a56497dcc6a25228d818af4f38.diff

LOG: Don't dereference from a dyn_cast<>. NFCI.

Use cast<> instead which will assert if it fails and not just return null.

Fixes clang static analyzer warning.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
index 230bc7adc07a..0abe42d22120 100644
--- a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
+++ b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
@@ -166,13 +166,13 @@ class AVROperand : public MCParsedAsmOperand {
     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);


        


More information about the llvm-commits mailing list