[PATCH] D148912: [Coverity] Fix explicit null dereferences
Akshay Khadse via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 21 20:16:41 PDT 2023
akshaykhadse added inline comments.
================
Comment at: llvm/include/llvm/ADT/SparseSet.h:206
assert(Idx < Universe && "Key out of range");
+ assert(Sparse != nullptr && "Invalid sparse type");
const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
----------------
skan wrote:
> `Sparse != nullptr` -> `Sparse`
"Sparse != nullptr" makes code more readable. Do you still want me to change this?
================
Comment at: llvm/include/llvm/CodeGen/PBQP/CostAllocator.h:103
EntrySet.insert(P.get());
- return PoolRef(std::move(P), &P->getValue());
}
----------------
skan wrote:
> I think it's a UB due to the sequence issue https://en.wikipedia.org/wiki/Sequence_point , right?
Yes. That's correct.
================
Comment at: llvm/include/llvm/CodeGen/SelectionDAGNodes.h:1138
inline unsigned SDValue::getOpcode() const {
+ assert(Node != nullptr && "Invalid Node");
return Node->getOpcode();
----------------
skan wrote:
> Why is this function special?
This is not special. But, Coverity identified that this is where the dereference happens. So, potentially all the functions that call this one will lead to Coverity warning sooner or later.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148912/new/
https://reviews.llvm.org/D148912
More information about the llvm-commits
mailing list