From 6aa10ae5bfd885a71d68d54363d338f35e8aad58 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Thu, 8 Oct 2020 20:18:18 +0100 Subject: [PATCH] [Transforms] visitCmpBlock - don't dereference a dyn_cast<>. NFCI. 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/Scalar/MergeICmps.cpp b/llvm/lib/Transforms/Scalar/MergeICmps.cpp index ce1e142..e3058af 100644 --- a/llvm/lib/Transforms/Scalar/MergeICmps.cpp +++ b/llvm/lib/Transforms/Scalar/MergeICmps.cpp @@ -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(Val); + const auto *const Const = cast(Val); LLVM_DEBUG(dbgs() << "const\n"); if (!Const->isZero()) return {}; LLVM_DEBUG(dbgs() << "false\n"); -- 2.7.4