diff options
author | Dávid Bolvanský <david.bolvansky@gmail.com> | 2019-11-06 19:20:48 +0100 |
---|---|---|
committer | Dávid Bolvanský <david.bolvansky@gmail.com> | 2019-11-07 19:30:29 +0100 |
commit | 6e655e58bc748d631fac90d969e77ceb04b884db (patch) | |
tree | a57dc733450c01c95c6a885e7d6fd8a9149d1bf8 | |
parent | f37b5c800e150ad915c4e0571edd2c92c0160d89 (diff) | |
download | bcm5719-llvm-6e655e58bc748d631fac90d969e77ceb04b884db.tar.gz bcm5719-llvm-6e655e58bc748d631fac90d969e77ceb04b884db.zip |
[AsmWritter] Fixed "null check after dereferencing" warning
Summary: The 'BB->getParent()' pointer was utilized before it was verified against nullptr. Check lines: 3567, 3581.
Reviewers: jyknight, RKSimon
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D69751
-rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index f811c842cf5..9ae15f49da8 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -3564,6 +3564,7 @@ void AssemblyWriter::printArgument(const Argument *Arg, AttributeSet Attrs) { /// printBasicBlock - This member is called for each basic block in a method. void AssemblyWriter::printBasicBlock(const BasicBlock *BB) { + assert(BB && BB->getParent() && "block without parent!"); bool IsEntryBlock = BB == &BB->getParent()->getEntryBlock(); if (BB->hasName()) { // Print out the label if it exists... Out << "\n"; @@ -3578,10 +3579,7 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) { Out << "<badref>:"; } - if (!BB->getParent()) { - Out.PadToColumn(50); - Out << "; Error: Block without parent!"; - } else if (!IsEntryBlock) { + if (!IsEntryBlock) { // Output predecessors for the block. Out.PadToColumn(50); Out << ";"; |