[clang] [alpha.webkit.UnretainedCallArgsChecker] Emit a warning for a non-const RetainPtr member (PR #184243)
Ryosuke Niwa via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 3 09:51:05 PST 2026
================
@@ -440,3 +440,45 @@ namespace call_with_adopt_ref {
adoptRef(new Obj)->method();
}
}
+
+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 at -1{{Call argument for 'this' parameter is uncounted and unsafe}}
+ m_obj.get()->method();
+ // expected-warning at -1{{Call argument for 'this' parameter is uncounted and unsafe}}
+ m_constObj->method();
----------------
rniwa wrote:
That's a good point. I haven't seen that coming up in WebKit often though probably because we don't use `const` function all that often.
https://github.com/llvm/llvm-project/pull/184243
More information about the cfe-commits
mailing list