[PATCH] D19632: [scan-build] fix logic error warnings emitted on llvm code base
Apelete Seketeli via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 27 15:06:06 PDT 2016
apelete created this revision.
apelete added reviewers: atrick, friedgold, hfinkel, jholewinski.
apelete added a subscriber: llvm-commits.
Herald added subscribers: mzolotukhin, jholewinski.
Fix the last few "called C++ object pointer is null" warnings emitted
by Clang Static Analyzer on the following files:
- lib/Transforms/Scalar/LoopStrengthReduce.cpp,
- lib/Transforms/Scalar/LoadCombine.cpp,
- lib/Transforms/ObjCARC/ObjCARCContract.cpp,
- lib/Target/XCore/XCoreInstrInfo.cpp,
- lib/Target/PowerPC/PPCInstrInfo.cpp,
- lib/Target/NVPTX/NVPTXISelLowering.cpp,
- lib/CodeGen/CriticalAntiDepBreaker.cpp.
Signed-off-by: Apelete Seketeli <apelete at seketeli.net>
http://reviews.llvm.org/D19632
Files:
lib/CodeGen/CriticalAntiDepBreaker.cpp
lib/Target/NVPTX/NVPTXISelLowering.cpp
lib/Target/PowerPC/PPCInstrInfo.cpp
lib/Target/XCore/XCoreInstrInfo.cpp
lib/Transforms/ObjCARC/ObjCARCContract.cpp
lib/Transforms/Scalar/LoadCombine.cpp
lib/Transforms/Scalar/LoopStrengthReduce.cpp
Index: lib/Transforms/Scalar/LoopStrengthReduce.cpp
===================================================================
--- lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -2877,6 +2877,7 @@
DEBUG(dbgs() << "Concealed chain head: " << *Head.UserInst << "\n");
return;
}
+ assert(IVSrc && "induction variable is needed to generate a chain");
DEBUG(dbgs() << "Generate chain at: " << *IVSrc << "\n");
Type *IVTy = IVSrc->getType();
Index: lib/Transforms/Scalar/LoadCombine.cpp
===================================================================
--- lib/Transforms/Scalar/LoadCombine.cpp
+++ lib/Transforms/Scalar/LoadCombine.cpp
@@ -188,10 +188,12 @@
// Find first load. This is where we put the new load.
LoadPOPPair FirstLP;
FirstLP.InsertOrder = -1u;
+ FirstLP.POP.Pointer = nullptr;
for (const auto &L : Loads)
if (L.InsertOrder < FirstLP.InsertOrder)
FirstLP = L;
+ assert(FirstLP.POP.Pointer && "could not find first load");
unsigned AddressSpace =
FirstLP.POP.Pointer->getType()->getPointerAddressSpace();
Index: lib/Transforms/ObjCARC/ObjCARCContract.cpp
===================================================================
--- lib/Transforms/ObjCARC/ObjCARCContract.cpp
+++ lib/Transforms/ObjCARC/ObjCARCContract.cpp
@@ -377,6 +377,7 @@
Type *I8XX = PointerType::getUnqual(I8X);
Value *Args[] = { Load->getPointerOperand(), New };
+ assert((Args[0] && Args[1]) && "is an empty Value array");
if (Args[0]->getType() != I8XX)
Args[0] = new BitCastInst(Args[0], I8XX, "", Store);
if (Args[1]->getType() != I8X)
Index: lib/Target/XCore/XCoreInstrInfo.cpp
===================================================================
--- lib/Target/XCore/XCoreInstrInfo.cpp
+++ lib/Target/XCore/XCoreInstrInfo.cpp
@@ -232,7 +232,8 @@
// If there are three terminators, we don't know what sort of block this is.
if (SecondLastInst && I != MBB.begin() && isUnpredicatedTerminator(*--I))
return true;
-
+
+ assert(SecondLastInst && "does not point to a valid instruction");
unsigned SecondLastOpc = SecondLastInst->getOpcode();
XCore::CondCode BranchCode = GetCondFromBranchOpc(SecondLastOpc);
Index: lib/Target/PowerPC/PPCInstrInfo.cpp
===================================================================
--- lib/Target/PowerPC/PPCInstrInfo.cpp
+++ lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -525,6 +525,7 @@
if (SecondLastInst && I != MBB.begin() && isUnpredicatedTerminator(*--I))
return true;
+ assert(SecondLastInst && "does not point to a valid instruction");
// If the block ends with PPC::B and PPC:BCC, handle it.
if (SecondLastInst->getOpcode() == PPC::BCC &&
LastInst->getOpcode() == PPC::B) {
Index: lib/Target/NVPTX/NVPTXISelLowering.cpp
===================================================================
--- lib/Target/NVPTX/NVPTXISelLowering.cpp
+++ lib/Target/NVPTX/NVPTXISelLowering.cpp
@@ -1628,7 +1628,7 @@
SmallVector<EVT, 4> LoadRetVTs;
EVT TheLoadType = VTs[i];
- if (retTy->isIntegerTy() && DL.getTypeAllocSizeInBits(retTy) < 32) {
+ if (retTy && retTy->isIntegerTy() && DL.getTypeAllocSizeInBits(retTy) < 32) {
// This is for integer types only, and specifically not for
// aggregates.
LoadRetVTs.push_back(MVT::i32);
Index: lib/CodeGen/CriticalAntiDepBreaker.cpp
===================================================================
--- lib/CodeGen/CriticalAntiDepBreaker.cpp
+++ lib/CodeGen/CriticalAntiDepBreaker.cpp
@@ -444,6 +444,7 @@
#ifndef NDEBUG
{
+ assert(Max && "does not point to any node in the scheduling DAG");
DEBUG(dbgs() << "Critical path has total latency "
<< (Max->getDepth() + Max->Latency) << "\n");
DEBUG(dbgs() << "Available regs:");
@@ -458,6 +459,7 @@
// Track progress along the critical path through the SUnit graph as we walk
// the instructions.
const SUnit *CriticalPathSU = Max;
+ assert(CriticalPathSU && "does not point to any node in the scheduling DAG");
MachineInstr *CriticalPathMI = CriticalPathSU->getInstr();
// Consider this pattern:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19632.55335.patch
Type: text/x-patch
Size: 4180 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160427/f74f166c/attachment.bin>
More information about the llvm-commits
mailing list