Skip to content

[webkit.NoUncountedMemberChecker] Fix a regression that every class is treated as if it's ref countable. #131249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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 @@ -223,7 +223,7 @@ class NoUncountedMemberChecker final : public RawPtrRefMemberChecker {
std::optional<bool>
isPtrCompatible(const clang::QualType,
const clang::CXXRecordDecl *R) const final {
return R && isRefCountable(R);
return R ? isRefCountable(R) : std::nullopt;
}

bool isPtrCls(const clang::CXXRecordDecl *R) const final {
Expand All @@ -246,7 +246,7 @@ class NoUncheckedPtrMemberChecker final : public RawPtrRefMemberChecker {
std::optional<bool>
isPtrCompatible(const clang::QualType,
const clang::CXXRecordDecl *R) const final {
return R && isCheckedPtrCapable(R);
return R ? isCheckedPtrCapable(R) : std::nullopt;
}

bool isPtrCls(const clang::CXXRecordDecl *R) const final {
Expand Down
10 changes: 9 additions & 1 deletion clang/test/Analysis/Checkers/WebKit/uncounted-members.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ namespace members {
};
}


namespace ignore_unions {
union Foo {
RefCountable* a;
Expand All @@ -60,3 +59,12 @@ void foo(RefCountable* t) {
}

} // ignore_system_header

namespace ignore_non_ref_countable {
struct Foo {
};

struct Bar {
Foo* foo;
};
}