From caff2acae13eebb83ca2f648ad787ab77c6e6271 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Tue, 17 Aug 2021 18:15:33 +0100 Subject: [PATCH] [AArch64] AArch64DAGToDAGISel::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. --- llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp index 58048869fa2e..e556533cb089 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp @@ -2965,8 +2965,8 @@ static int getIntOperandFromRegisterString(StringRef RegString) { // form described in getIntOperandsFromRegsterString) or is a named register // known by the MRS SysReg mapper. bool AArch64DAGToDAGISel::tryReadRegister(SDNode *N) { - const MDNodeSDNode *MD = dyn_cast(N->getOperand(1)); - const MDString *RegString = dyn_cast(MD->getMD()->getOperand(0)); + const auto *MD = cast(N->getOperand(1)); + const auto *RegString = cast(MD->getMD()->getOperand(0)); SDLoc DL(N); int Reg = getIntOperandFromRegisterString(RegString->getString()); @@ -3011,8 +3011,8 @@ bool AArch64DAGToDAGISel::tryReadRegister(SDNode *N) { // form described in getIntOperandsFromRegsterString) or is a named register // known by the MSR SysReg mapper. bool AArch64DAGToDAGISel::tryWriteRegister(SDNode *N) { - const MDNodeSDNode *MD = dyn_cast(N->getOperand(1)); - const MDString *RegString = dyn_cast(MD->getMD()->getOperand(0)); + const auto *MD = cast(N->getOperand(1)); + const auto *RegString = cast(MD->getMD()->getOperand(0)); SDLoc DL(N); int Reg = getIntOperandFromRegisterString(RegString->getString());