[clang] [Clang] Protect ObjCMethodList assignment operator against self-assignment (PR #97933)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 16 10:51:15 PDT 2024
smanna12 wrote:
> As far as I can tell, `ObjCMethodList` is already self-assignment safe so long as `PointerIntPair` is. It looks like the latter might not be though since its copy assignment operator (as implemented via `PunnedPointer`) uses `memcpy` and it does not guard against self-assignment. I wonder if a change should instead be made there. Can you share more details from the static analysis report?
Thank you @tahonermann for reviews and feedbacks.
This is what static analyzer tool complains. It does not provide much detailes:
```
In clang::ObjCMethodList::operator =(clang::ObjCMethodList const &): Assignment operator does not check for self-assignment
ObjCMethodList &operator=(const ObjCMethodList &L) {
//Unsafe assignment operator (SELF_ASSIGN)
self_assign: No protection against the object assigning to itself.
MethodAndHasMoreThanOneDecl = L.MethodAndHasMoreThanOneDecl;
NextAndExtraBits = L.NextAndExtraBits;
return *this;
}
https://github.com/llvm/llvm-project/pull/97933
More information about the cfe-commits
mailing list