[llvm] 1e770f0 - [ARM] ARMDAGToDAGISel::tryReadRegister/tryWriteRegister - don't dereference dyn_cast<> results.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 17 10:41:11 PDT 2021
Author: Simon Pilgrim
Date: 2021-08-17T18:40:59+01:00
New Revision: 1e770f0388c92bdb5bd474b8c4a8fce4f0c62b74
URL: https://github.com/llvm/llvm-project/commit/1e770f0388c92bdb5bd474b8c4a8fce4f0c62b74
DIFF: https://github.com/llvm/llvm-project/commit/1e770f0388c92bdb5bd474b8c4a8fce4f0c62b74.diff
LOG: [ARM] ARMDAGToDAGISel::tryReadRegister/tryWriteRegister - don't dereference dyn_cast<> results.
dyn_cast<> can return nullptr if the cast is illegal, use cast<> instead which will assert that the cast is correct.
Fixes static analyser warnings.
Added:
Modified:
llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
index 7c238a1099d8..372f79660d03 100644
--- a/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
+++ b/llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
@@ -5499,8 +5499,8 @@ static int getARClassRegisterMask(StringRef Reg, StringRef Flags) {
// using the supplied metadata string to select the instruction node to use
// and the registers/masks to construct as operands for the node.
bool ARMDAGToDAGISel::tryReadRegister(SDNode *N){
- const MDNodeSDNode *MD = dyn_cast<MDNodeSDNode>(N->getOperand(1));
- const MDString *RegString = dyn_cast<MDString>(MD->getMD()->getOperand(0));
+ const auto *MD = cast<MDNodeSDNode>(N->getOperand(1));
+ const auto *RegString = cast<MDString>(MD->getMD()->getOperand(0));
bool IsThumb2 = Subtarget->isThumb2();
SDLoc DL(N);
@@ -5614,8 +5614,8 @@ bool ARMDAGToDAGISel::tryReadRegister(SDNode *N){
// using the supplied metadata string to select the instruction node to use
// and the registers/masks to use in the nodes
bool ARMDAGToDAGISel::tryWriteRegister(SDNode *N){
- const MDNodeSDNode *MD = dyn_cast<MDNodeSDNode>(N->getOperand(1));
- const MDString *RegString = dyn_cast<MDString>(MD->getMD()->getOperand(0));
+ const auto *MD = cast<MDNodeSDNode>(N->getOperand(1));
+ const auto *RegString = cast<MDString>(MD->getMD()->getOperand(0));
bool IsThumb2 = Subtarget->isThumb2();
SDLoc DL(N);
More information about the llvm-commits
mailing list