[llvm] r372758 - SafepointIRVerifier - silence static analyzer dyn_cast<Instruction> null dereference warnings. NFCI.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 06:57:44 PDT 2019


Author: rksimon
Date: Tue Sep 24 06:57:44 2019
New Revision: 372758

URL: http://llvm.org/viewvc/llvm-project?rev=372758&view=rev
Log:
SafepointIRVerifier - silence static analyzer dyn_cast<Instruction> null dereference warnings. NFCI.

The static analyzer is warning about a potential null dereference, but we should be able to use cast<Instruction> directly and if not assert will fire for us.

Modified:
    llvm/trunk/lib/IR/SafepointIRVerifier.cpp

Modified: llvm/trunk/lib/IR/SafepointIRVerifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/SafepointIRVerifier.cpp?rev=372758&r1=372757&r2=372758&view=diff
==============================================================================
--- llvm/trunk/lib/IR/SafepointIRVerifier.cpp (original)
+++ llvm/trunk/lib/IR/SafepointIRVerifier.cpp Tue Sep 24 06:57:44 2019
@@ -102,11 +102,11 @@ public:
   }
 
   bool isDeadEdge(const Use *U) const {
-    assert(dyn_cast<Instruction>(U->getUser())->isTerminator() &&
+    assert(cast<Instruction>(U->getUser())->isTerminator() &&
            "edge must be operand of terminator");
     assert(cast_or_null<BasicBlock>(U->get()) &&
            "edge must refer to basic block");
-    assert(!isDeadBlock(dyn_cast<Instruction>(U->getUser())->getParent()) &&
+    assert(!isDeadBlock(cast<Instruction>(U->getUser())->getParent()) &&
            "isDeadEdge() must be applied to edge from live block");
     return DeadEdges.count(U);
   }




More information about the llvm-commits mailing list