[llvm] df9ae80 - [AVR] Fix null dereference warning. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 8 11:12:59 PDT 2020
Author: Simon Pilgrim
Date: 2020-10-08T19:04:29+01:00
New Revision: df9ae806bba497e9fd76ff0da74c1ab8ab08d75b
URL: https://github.com/llvm/llvm-project/commit/df9ae806bba497e9fd76ff0da74c1ab8ab08d75b
DIFF: https://github.com/llvm/llvm-project/commit/df9ae806bba497e9fd76ff0da74c1ab8ab08d75b.diff
LOG: [AVR] Fix null dereference warning. NFCI.
We were checking if the ConstantSDNode was null but then immediately dereferencing it afterward - fold these both into a single check. Use the APInt::ult() helper as well.
Found by clang static analyzer.
Added:
Modified:
llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp b/llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp
index fe31fa42c403..df382d553753 100644
--- a/llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp
+++ b/llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp
@@ -242,10 +242,7 @@ bool AVRDAGToDAGISel::SelectInlineAsmMemoryOperand(const SDValue &Op,
ConstantSDNode *ImmNode = dyn_cast<ConstantSDNode>(ImmOp);
unsigned Reg;
- bool CanHandleRegImmOpt = true;
-
- CanHandleRegImmOpt &= ImmNode != 0;
- CanHandleRegImmOpt &= ImmNode->getAPIntValue().getZExtValue() < 64;
+ bool CanHandleRegImmOpt = ImmNode && ImmNode->getAPIntValue().ult(64);
if (CopyFromRegOp->getOpcode() == ISD::CopyFromReg) {
RegisterSDNode *RegNode =
More information about the llvm-commits
mailing list