[clang] [llvm] [Clang] Protect ObjCMethodList assignment operator against self-assignment (PR #97933)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 4 20:15:01 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 details:
>
> ```
> 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;
> }
> ```
I have updated patch. @tahonermann, could you please revisit the patch? Thank you
https://github.com/llvm/llvm-project/pull/97933
More information about the llvm-commits
mailing list