diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2016-11-04 06:59:50 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2016-11-04 06:59:50 +0000 |
commit | d9ef4b6601bec251c48e7d7613042f9a4c62582b (patch) | |
tree | f1f6cb2ca202d44cce0a091abc3ab1c05ca5b3b0 /llvm/lib | |
parent | 0f139b4f7164302d5e654dc2b243bb2e2fb1ddfc (diff) | |
download | bcm5719-llvm-d9ef4b6601bec251c48e7d7613042f9a4c62582b.tar.gz bcm5719-llvm-d9ef4b6601bec251c48e7d7613042f9a4c62582b.zip |
Only log the visit of a return instruction if we in fact found a return
instruction.
This avoids dereferencing null in the debug logging if the instruction
was not in fact a return instruction. This potential bug was found by
PVS-Studio.
This actually fixes the last of the "dereferenced a pointer before
checking it for null" reports in the recent PVS-Studio run. However,
there are quite a few reports of this nature that I did not do anything
to fix because they are pretty glaring false positives. They usually
took the form of quite clear correlated checks or a check made in
a separate function. I've even added asserts anywhere this correlation
wasn't pretty obvious and fundamental to the code.
llvm-svn: 285988
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp index ed5063cdf1a..136d54a6cb7 100644 --- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp +++ b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp @@ -2086,12 +2086,11 @@ void ObjCARCOpt::OptimizeReturns(Function &F) { SmallPtrSet<const BasicBlock *, 4> Visited; for (BasicBlock &BB: F) { ReturnInst *Ret = dyn_cast<ReturnInst>(&BB.back()); - - DEBUG(dbgs() << "Visiting: " << *Ret << "\n"); - if (!Ret) continue; + DEBUG(dbgs() << "Visiting: " << *Ret << "\n"); + const Value *Arg = GetRCIdentityRoot(Ret->getOperand(0)); // Look for an ``autorelease'' instruction that is a predecessor of Ret and |