[llvm-dev] [llvm] r260949 - [Hexagon] Hoist nonnull assert up.

Colin LeMahieu via llvm-dev llvm-dev at lists.llvm.org
Wed Feb 17 08:32:36 PST 2016


Good catch.

 

From: llvm-commits [mailto:llvm-commits-bounces at lists.llvm.org] On Behalf Of David Blaikie via llvm-commits
Sent: Tuesday, February 16, 2016 7:28 PM
To: Benjamin Kramer
Cc: llvm-commits
Subject: Re: [llvm] r260949 - [Hexagon] Hoist nonnull assert up.

 

 

 

On Tue, Feb 16, 2016 at 1:53 AM, Benjamin Kramer via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org> > wrote:

Author: d0k
Date: Tue Feb 16 03:53:47 2016
New Revision: 260949

URL: http://llvm.org/viewvc/llvm-project?rev=260949 <http://llvm.org/viewvc/llvm-project?rev=260949&view=rev> &view=rev
Log:
[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.

Modified:
    llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
    llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp

Modified: llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp?rev=260949 <http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp?rev=260949&r1=260948&r2=260949&view=diff> &r1=260948&r2=260949&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp Tue Feb 16 03:53:47 2016
@@ -592,7 +592,6 @@ public:

   static std::unique_ptr<HexagonOperand> 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;

Modified: llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp?rev=260949 <http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp?rev=260949&r1=260948&r2=260949&view=diff> &r1=260948&r2=260949&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.cpp Tue Feb 16 03:53:47 2016
@@ -193,6 +193,7 @@ MCInstrDesc const &HexagonMCInstrInfo::g

 MCExpr const &HexagonMCInstrInfo::getExpr(MCExpr const &Expr) {
   HexagonMCExpr const &HExpr = *llvm::cast<HexagonMCExpr>(&Expr);

 

Speaking of weird null/reference things, perhaps we can drop the &/* in this line ^ since llvm::cast supports casting refs?

 

+  assert(HExpr.getExpr());
   return *HExpr.getExpr();
 }



_______________________________________________
llvm-commits mailing list
llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org> 
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160217/3bf22306/attachment.html>


More information about the llvm-dev mailing list