Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,10 @@ class TrivialFunctionAnalysisVisitor
if (!Callee)
return false;

auto Name = safeGetName(Callee);
if (Name == "ref" || Name == "incrementCheckedPtrCount")
return true;

std::optional<bool> IsGetterOfRefCounted = isGetterOfSafePtr(Callee);
if (IsGetterOfRefCounted && *IsGetterOfRefCounted)
return true;
Expand Down
19 changes: 19 additions & 0 deletions clang/test/Analysis/Checkers/WebKit/call-args-checked-ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,22 @@ namespace call_with_explicit_temporary_obj {
CheckedPtr { provide() }->method();
}
}

namespace call_with_checked_ptr {

class Foo : public CheckedObj {
public:
CheckedPtr<CheckedObj> obj1() { return m_obj; }
CheckedRef<CheckedObj> obj2() { return *m_obj; }
private:
CheckedObj* m_obj;
};

Foo* getFoo();

void bar() {
getFoo()->obj1()->method();
getFoo()->obj2()->method();
}

}
4 changes: 4 additions & 0 deletions clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ class RefCounted {
void trivial65() {
__libcpp_verbose_abort("%s", "aborting");
}
RefPtr<RefCounted> trivial66() { return children[0]; }
Ref<RefCounted> trivial67() { return *children[0]; }

static RefCounted& singleton() {
static RefCounted s_RefCounted;
Expand Down Expand Up @@ -550,6 +552,8 @@ class UnrelatedClass {
getFieldTrivial().trivial63(); // no-warning
getFieldTrivial().trivial64(); // no-warning
getFieldTrivial().trivial65(); // no-warning
getFieldTrivial().trivial66()->trivial6(); // no-warning
getFieldTrivial().trivial67()->trivial6(); // no-warning

RefCounted::singleton().trivial18(); // no-warning
RefCounted::singleton().someFunction(); // no-warning
Expand Down
Loading