diff options
author | Richard Trieu <rtrieu@google.com> | 2014-06-09 22:53:16 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2014-06-09 22:53:16 +0000 |
commit | f31ecd39273231fccc53785f518023d70f85a02a (patch) | |
tree | c6f05f5eef00db27c074ec3b5e900c63df3e0c7c /lib/IR | |
parent | 8aeca44558234ae3703c565854c31d38034e56cb (diff) | |
download | llvm-f31ecd39273231fccc53785f518023d70f85a02a.tar.gz llvm-f31ecd39273231fccc53785f518023d70f85a02a.tar.bz2 llvm-f31ecd39273231fccc53785f518023d70f85a02a.tar.xz |
Removing an "if (!this)" check from two print methods. The condition will
never be true in a well-defined context. The checking for null pointers
has been moved into the caller logic so it does not rely on undefined behavior.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210497 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR')
-rw-r--r-- | lib/IR/AsmWriter.cpp | 8 | ||||
-rw-r--r-- | lib/IR/Core.cpp | 2 |
2 files changed, 2 insertions, 8 deletions
diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp index fc73a61f9f..7afefdc7ac 100644 --- a/lib/IR/AsmWriter.cpp +++ b/lib/IR/AsmWriter.cpp @@ -2156,10 +2156,6 @@ void NamedMDNode::print(raw_ostream &ROS) const { } void Type::print(raw_ostream &OS) const { - if (!this) { - OS << "<null Type>"; - return; - } TypePrinting TP; TP.print(const_cast<Type*>(this), OS); @@ -2172,10 +2168,6 @@ void Type::print(raw_ostream &OS) const { } void Value::print(raw_ostream &ROS) const { - if (!this) { - ROS << "printing a <null> value\n"; - return; - } formatted_raw_ostream OS(ROS); if (const Instruction *I = dyn_cast<Instruction>(this)) { const Function *F = I->getParent() ? I->getParent()->getParent() : nullptr; diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp index aa373f602a..f24704c61c 100644 --- a/lib/IR/Core.cpp +++ b/lib/IR/Core.cpp @@ -281,6 +281,7 @@ char *LLVMPrintTypeToString(LLVMTypeRef Ty) { std::string buf; raw_string_ostream os(buf); + assert(unwrap(Ty) != nullptr && "Expecting non-null Type"); unwrap(Ty)->print(os); os.flush(); @@ -531,6 +532,7 @@ char* LLVMPrintValueToString(LLVMValueRef Val) { std::string buf; raw_string_ostream os(buf); + assert(unwrap(Val) != nullptr && "Expecting non-null Value"); unwrap(Val)->print(os); os.flush(); |