[llvm] 09feea9 - [IR] move/change null-check to assert
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 29 06:29:00 PDT 2019
Author: Sanjay Patel
Date: 2019-10-29T09:28:47-04:00
New Revision: 09feea972d0f2c7b4f16719f3c70ac0795770330
URL: https://github.com/llvm/llvm-project/commit/09feea972d0f2c7b4f16719f3c70ac0795770330
DIFF: https://github.com/llvm/llvm-project/commit/09feea972d0f2c7b4f16719f3c70ac0795770330.diff
LOG: [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.
Added:
Modified:
llvm/lib/IR/Constants.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index ab4e478f700a..eb40b291b005 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;
}
More information about the llvm-commits
mailing list