================
@@ -355,14 +355,30 @@ class RetainPtrCtorAdoptChecker
void visitBinaryOperator(const BinaryOperator *BO) const {
if (!BO->isAssignmentOp())
return;
- if (!isa<ObjCIvarRefExpr>(BO->getLHS()))
- return;
+ auto *LHS = BO->getLHS();
auto *RHS = BO->getRHS()->IgnoreParenCasts();
- const Expr *Inner = nullptr;
- if (isAllocInit(RHS, &Inner)) {
- CreateOrCopyFnCall.insert(RHS);
- if (Inner)
- CreateOrCopyFnCall.insert(Inner);
+ if (isa<ObjCIvarRefExpr>(LHS)) {
+ const Expr *Inner = nullptr;
+ if (isAllocInit(RHS, &Inner)) {
+ CreateOrCopyFnCall.insert(RHS);
+ if (Inner)
+ CreateOrCopyFnCall.insert(Inner);
+ }
+ return;
+ } else if (auto *UO = dyn_cast<UnaryOperator>(LHS)) {
+ auto OpCode = UO->getOpcode();
+ if (OpCode == UO_Deref) {
----------------
steakhal wrote:
I think we could just nest this. Only used there.
```suggestion
if (UO->getOpcode() == UO_Deref) {
```
https://github.com/llvm/llvm-project/pull/161633
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits