From: Sanjay Patel Date: Tue, 29 Oct 2019 13:25:36 +0000 (-0400) Subject: [IR] move/change null-check to assert X-Git-Tag: llvmorg-11-init~5591 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=09feea972d0f2c7b4f16719f3c70ac0795770330;p=platform%2Fupstream%2Fllvm.git [IR] move/change null-check to assert This should trigger a dereference before null-check warning, but I don't see it when building with clang. In any case, the current and known future users of this helper require non-null args, so I'm converting the 'if' to an assert. --- diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp index ab4e478..eb40b29 100644 --- a/llvm/lib/IR/Constants.cpp +++ b/llvm/lib/IR/Constants.cpp @@ -596,8 +596,9 @@ void Constant::removeDeadConstantUsers() const { } Constant *Constant::replaceUndefsWith(Constant *C, Constant *Replacement) { + assert(C && Replacement && "Expected non-nullptr constant arguments"); Type *Ty = C->getType(); - if (C && match(C, m_Undef())) { + if (match(C, m_Undef())) { assert(Ty == Replacement->getType() && "Expected matching types"); return Replacement; }