https://github.com/rniwa updated 
https://github.com/llvm/llvm-project/pull/224464

>From 9a43d46631d90e7a53aa911d02324a1c96727fda Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa <[email protected]>
Date: Thu, 17 Sep 2026 15:45:41 -0700
Subject: [PATCH] Revert "[alpha.webkit.UnretainedCallArgsChecker] Emit a
 warning for a non-const RetainPtr member (llvm#184243)"

This reverts bf005a1227a4822c7c2535dd5f5f3626fbe441b2.
---
 .../Checkers/WebKit/ASTUtils.cpp              |  11 +-
 .../Analysis/Checkers/WebKit/call-args.cpp    |  53 -----
 .../Checkers/WebKit/objc-mock-types.h         |   4 -
 .../WebKit/unretained-call-args-member.mm     | 184 ------------------
 4 files changed, 3 insertions(+), 249 deletions(-)
 delete mode 100644 
clang/test/Analysis/Checkers/WebKit/unretained-call-args-member.mm

diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
index 06eaa0673143f..dea03c7390946 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
@@ -111,14 +111,9 @@ bool tryToFindPtrOrigin(
         if (auto *decl = memberCall->getMethodDecl()) {
           std::optional<bool> IsGetterOfRefCt = isGetterOfSafePtr(decl);
           if (IsGetterOfRefCt && *IsGetterOfRefCt) {
-            E = memberCall->getImplicitObjectArgument()->IgnoreParenCasts();
-            if (auto *DRE = dyn_cast<DeclRefExpr>(E)) {
-              if (auto *Decl = dyn_cast_or_null<VarDecl>(DRE->getDecl())) {
-                if (Decl->isLocalVarDeclOrParm()) {
-                  if (StopAtFirstRefCountedObj)
-                    return callback(E, true);
-                }
-              }
+            E = memberCall->getImplicitObjectArgument();
+            if (StopAtFirstRefCountedObj) {
+              return callback(E, true);
             }
             continue;
           }
diff --git a/clang/test/Analysis/Checkers/WebKit/call-args.cpp 
b/clang/test/Analysis/Checkers/WebKit/call-args.cpp
index 5e9f1591692e6..b4dc1b1038ef5 100644
--- a/clang/test/Analysis/Checkers/WebKit/call-args.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/call-args.cpp
@@ -500,59 +500,6 @@ namespace call_with_adopt_ref {
   }
 }
 
-namespace call_on_member {
-
-  class SomeObj {
-  public:
-    static Ref<SomeObj> create() { return adoptRef(*new SomeObj); }
-
-    void ref() const;
-    void deref() const;
-
-    void doWork() {
-      m_obj->method();
-      // expected-warning@-1{{Function argument 'this->m_obj' (parameter 
'this' to 'RefCountable::method') is a raw pointer to RefPtr-capable type 
'RefCountable'}}
-      m_obj.get()->method();
-      // expected-warning@-1{{Function argument 'this->m_obj.get()' (parameter 
'this' to 'RefCountable::method') is a raw pointer to RefPtr-capable type 
'RefCountable'}}
-      m_constObj->method();
-    }
-
-    void localWork() {
-      RefPtr obj = provide();
-      obj->method();
-      obj.get()->method();
-    }
-
-    void argWork(RefPtr<RefCountable> arg) {
-      arg->method();
-      arg.get()->method();
-    }
-
-    void temporaryWork() {
-      RefPtr { provide() }->method();
-      RefPtr { provide() }.get()->method();
-    }
-
-    void work();
-
-    RefCountable& constObj() const { return *m_constObj; }
-
-  private:
-    RefPtr<RefCountable> m_obj;
-    const RefPtr<RefCountable> m_constObj;
-  };
-
-  SomeObj* provide();
-
-  void foo() {
-    provide()->constObj().method();
-    // expected-warning@-1{{Function argument 'provide()->constObj()' 
(parameter 'this' to 'RefCountable::method') is a raw pointer to RefPtr-capable 
type 'RefCountable'}}
-    Ref { provide()->constObj() }->method();
-    RefPtr { provide() }->constObj().method();
-  }
-
-}
-
 namespace call_with_weak_ptr {
 
   class RefCountableWithWeakPtr : public RefCountable, public 
CanMakeWeakPtr<RefCountableWithWeakPtr> {
diff --git a/clang/test/Analysis/Checkers/WebKit/objc-mock-types.h 
b/clang/test/Analysis/Checkers/WebKit/objc-mock-types.h
index aad2a6185d0b0..b0cbf0756c2d0 100644
--- a/clang/test/Analysis/Checkers/WebKit/objc-mock-types.h
+++ b/clang/test/Analysis/Checkers/WebKit/objc-mock-types.h
@@ -449,9 +449,6 @@ template<typename T> static inline void releaseOSObject(T 
ptr)
 
 template<typename T> class OSObjectPtr {
 public:
-    using ValueType = typename RemovePointer<T>::Type;
-    using PtrType = ValueType*;
-
     OSObjectPtr()
         : m_ptr(nullptr)
     {
@@ -465,7 +462,6 @@ template<typename T> class OSObjectPtr {
 
     T get() const { return m_ptr; }
 
-    operator PtrType() const { return m_ptr; }
     explicit operator bool() const { return m_ptr; }
     bool operator!() const { return !m_ptr; }
 
diff --git a/clang/test/Analysis/Checkers/WebKit/unretained-call-args-member.mm 
b/clang/test/Analysis/Checkers/WebKit/unretained-call-args-member.mm
deleted file mode 100644
index d680b2e348670..0000000000000
--- a/clang/test/Analysis/Checkers/WebKit/unretained-call-args-member.mm
+++ /dev/null
@@ -1,184 +0,0 @@
-// UNSUPPORTED: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
-// RUN: %clang_analyze_cc1 
-analyzer-checker=alpha.webkit.UnretainedCallArgsChecker -verify %s
-
-#include "objc-mock-types.h"
-
-void consume_cf(CFMutableArrayRef);
-void consume_obj(SomeObj *);
-
-namespace call_args_const_retainptr_member {
-
-class Foo {
-public:
-  Foo();
-  void bar();
-
-private:
-  const RetainPtr<SomeObj> m_constObj;
-  RetainPtr<SomeObj> m_obj;
-};
-
-void Foo::bar() {
-  [m_constObj doWork]; // no-warning
-  [m_obj doWork]; // expected-warning{{Receiver 'this->m_obj' (to '-[SomeObj 
doWork]') is a raw pointer to RetainPtr-capable type 'SomeObj'}}
-}
-
-} // namespace call_args_const_retainptr_member
-
-namespace call_args_const_retainptr_cf_member {
-
-class Foo {
-public:
-  Foo();
-  void bar();
-
-private:
-  const RetainPtr<CFMutableArrayRef> m_cf1;
-  RetainPtr<CFMutableArrayRef> m_cf2;
-};
-
-void Foo::bar() {
-  consume_cf(m_cf1.get()); // no-warning
-  consume_cf(m_cf2.get()); // expected-warning{{Function argument 
'this->m_cf2.get()' (to 'consume_cf') is a RetainPtr-capable type 'CFArrayRef'}}
-}
-
-} // namespace call_args_const_retainptr_cf_member
-
-namespace call_args_const_retainptr_struct_member {
-
-struct Bar {
-  Bar();
-  void baz();
-
-  const RetainPtr<SomeObj> m_constObj;
-  RetainPtr<SomeObj> m_obj;
-};
-
-void Bar::baz() {
-  [m_constObj doWork]; // no-warning
-  [m_obj doWork]; // expected-warning{{Receiver 'this->m_obj' (to '-[SomeObj 
doWork]') is a raw pointer to RetainPtr-capable type 'SomeObj'}}
-}
-
-} // namespace call_args_const_retainptr_struct_member
-
-namespace call_args_const_retainptr_cf_struct_member {
-
-struct Bar {
-  Bar();
-  void baz();
-
-  const RetainPtr<CFMutableArrayRef> m_cf1;
-  RetainPtr<CFMutableArrayRef> m_cf2;
-};
-
-void Bar::baz() {
-  consume_cf(m_cf1.get()); // no-warning
-  consume_cf(m_cf2.get()); // expected-warning{{Function argument 
'this->m_cf2.get()' (to 'consume_cf') is a RetainPtr-capable type 'CFArrayRef'}}
-}
-
-} // namespace call_args_const_retainptr_cf_struct_member
-
-namespace call_args_const_retainptr_get_as_objc_arg {
-
-class Foo {
-public:
-  Foo();
-  void bar();
-
-private:
-  const RetainPtr<SomeObj> m_constObj;
-  RetainPtr<SomeObj> m_obj;
-};
-
-void Foo::bar() {
-  consume_obj(m_constObj.get()); // no-warning
-  consume_obj(m_obj.get()); // expected-warning{{Function argument 
'this->m_obj.get()' (to 'consume_obj') is a RetainPtr-capable type 
'WTF::RetainPtr<SomeObj>::PtrType'}}
-}
-
-} // namespace call_args_const_retainptr_get_as_objc_arg
-
-namespace call_args_const_retainptr_implicit_conv_arg {
-
-class Foo {
-public:
-  Foo();
-  void bar();
-
-private:
-  const RetainPtr<SomeObj> m_constObj;
-  RetainPtr<SomeObj> m_obj;
-};
-
-void Foo::bar() {
-  consume_obj(m_constObj); // no-warning
-  consume_obj(m_obj); // expected-warning{{Function argument 'this->m_obj' (to 
'consume_obj') is a RetainPtr-capable type 'WTF::RetainPtr<SomeObj>::PtrType'}}
-}
-
-} // namespace call_args_const_retainptr_implicit_conv_arg
-
-namespace call_args_const_osobjectptr_member {
-
-class Foo {
-public:
-  Foo();
-  void bar();
-
-private:
-  const OSObjectPtr<SomeObj *> m_constObj;
-  OSObjectPtr<SomeObj *> m_obj;
-};
-
-void Foo::bar() {
-  consume_obj(m_constObj.get()); // no-warning
-  consume_obj(m_obj.get()); // expected-warning{{Function argument 
'this->m_obj.get()' (to 'consume_obj') is a raw pointer to RetainPtr-capable 
type 'SomeObj'}}
-}
-
-} // namespace call_args_const_osobjectptr_member
-
-namespace call_args_const_osobjectptr_receiver {
-
-class Foo {
-public:
-  Foo();
-  void bar();
-
-private:
-  const OSObjectPtr<SomeObj *> m_constObj;
-  OSObjectPtr<SomeObj *> m_obj;
-};
-
-void Foo::bar() {
-  [m_constObj doWork]; // no-warning
-  [m_obj doWork]; // expected-warning{{Receiver 'this->m_obj' (to '-[SomeObj 
doWork]') is a raw pointer to RetainPtr-capable type 'SomeObj'}}
-}
-
-} // namespace call_args_const_osobjectptr_receiver
-
-namespace call_args_retainptr_local {
-
-void testLocal(SomeObj *input) {
-  RetainPtr<SomeObj> localObj = input;
-  [localObj doWork]; // no-warning
-  consume_obj(localObj.get()); // no-warning
-  consume_cf(RetainPtr<CFMutableArrayRef>().get()); // no-warning
-}
-
-} // namespace call_args_retainptr_local
-
-namespace call_args_retainptr_protected_member {
-
-class Foo {
-public:
-  Foo();
-  void bar();
-
-private:
-  RetainPtr<SomeObj> m_obj;
-};
-
-void Foo::bar() {
-  auto protectedObj = m_obj;
-  [protectedObj doWork]; // no-warning (local copy is safe)
-}
-
-} // namespace call_args_retainptr_protected_member

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to