[Transforms] visitCmpBlock - don't dereference a dyn_cast<>. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 8 Oct 2020 19:18:18 +0000 (20:18 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Thu, 8 Oct 2020 19:18:32 +0000 (20:18 +0100)
Use cast<> as we immediately dereference the pointer afterwards - cast<> will assert if we fail.

Prevents clang static analyzer warning that we could deference a null pointer.

llvm/lib/Transforms/Scalar/MergeICmps.cpp

index ce1e142..e3058af 100644 (file)
@@ -372,7 +372,7 @@ BCECmpBlock visitCmpBlock(Value *const Val, BasicBlock *const Block,
   } else {
     // In this case, we expect a constant incoming value (the comparison is
     // chained).
-    const auto *const Const = dyn_cast<ConstantInt>(Val);
+    const auto *const Const = cast<ConstantInt>(Val);
     LLVM_DEBUG(dbgs() << "const\n");
     if (!Const->isZero()) return {};
     LLVM_DEBUG(dbgs() << "false\n");