From 986a49b0360109c10ea0c9fa735730ce18d435a6 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 16 Feb 2016 09:53:47 +0000 Subject: [PATCH] [Hexagon] Hoist nonnull assert up. Once a pointer is turned into a reference it cannot be nullptr, clang rightfully warns about this assert being a tautology. Put the assert before the reference is created. llvm-svn: 260949 --- llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp | 1 - llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp b/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp index 9738e55..8b8eb4a 100644 --- a/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp +++ b/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp @@ -592,7 +592,6 @@ public: static std::unique_ptr CreateImm(const MCExpr *Val, SMLoc S, SMLoc E) { - assert(&HexagonMCInstrInfo::getExpr(*Val) != nullptr); HexagonOperand *Op = new HexagonOperand(Immediate); Op->Imm.Val = Val; Op->Imm.MustExtend = false; diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp index eed635f..9b3d11a 100644 --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp @@ -193,6 +193,7 @@ MCInstrDesc const &HexagonMCInstrInfo::getDesc(MCInstrInfo const &MCII, MCExpr const &HexagonMCInstrInfo::getExpr(MCExpr const &Expr) { HexagonMCExpr const &HExpr = *llvm::cast(&Expr); + assert(HExpr.getExpr()); return *HExpr.getExpr(); } -- 2.7.4