[IR] move/change null-check to assert
authorSanjay Patel <spatel@rotateright.com>
Tue, 29 Oct 2019 13:25:36 +0000 (09:25 -0400)
committerSanjay Patel <spatel@rotateright.com>
Tue, 29 Oct 2019 13:28:47 +0000 (09:28 -0400)
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.

llvm/lib/IR/Constants.cpp

index ab4e478..eb40b29 100644 (file)
@@ -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;
   }