[llvm] 6aa10ae - [Transforms] visitCmpBlock - don't dereference a dyn_cast<>. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 8 12:29:44 PDT 2020
Author: Simon Pilgrim
Date: 2020-10-08T20:18:32+01:00
New Revision: 6aa10ae5bfd885a71d68d54363d338f35e8aad58
URL: https://github.com/llvm/llvm-project/commit/6aa10ae5bfd885a71d68d54363d338f35e8aad58
DIFF: https://github.com/llvm/llvm-project/commit/6aa10ae5bfd885a71d68d54363d338f35e8aad58.diff
LOG: [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.
Added:
Modified:
llvm/lib/Transforms/Scalar/MergeICmps.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/MergeICmps.cpp b/llvm/lib/Transforms/Scalar/MergeICmps.cpp
index ce1e142101b8..e3058af73c11 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<ConstantInt>(Val);
+ const auto *const Const = cast<ConstantInt>(Val);
LLVM_DEBUG(dbgs() << "const\n");
if (!Const->isZero()) return {};
LLVM_DEBUG(dbgs() << "false\n");
More information about the llvm-commits
mailing list