Skip to content

Commit bb0cc69

Browse files
authoredMar 18, 2025··
[webkit.NoUncountedMemberChecker] Fix a regression that every class is treated as if it's ref countable. (#131249)
This PR fixes a regression that webkit.NoUncountedMemberChecker and alpha.webkit.NoUncheckedMemberChecker emits warnings for every class as if they supported ref counting and checked ptr because we were erroneously coercing the return value of isRefCountable and isCheckedPtrCapable, which is std::optional<bool>, to boolean values.
1 parent b7ed5c8 commit bb0cc69

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed
 

‎clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class NoUncountedMemberChecker final : public RawPtrRefMemberChecker {
223223
std::optional<bool>
224224
isPtrCompatible(const clang::QualType,
225225
const clang::CXXRecordDecl *R) const final {
226-
return R && isRefCountable(R);
226+
return R ? isRefCountable(R) : std::nullopt;
227227
}
228228

229229
bool isPtrCls(const clang::CXXRecordDecl *R) const final {
@@ -246,7 +246,7 @@ class NoUncheckedPtrMemberChecker final : public RawPtrRefMemberChecker {
246246
std::optional<bool>
247247
isPtrCompatible(const clang::QualType,
248248
const clang::CXXRecordDecl *R) const final {
249-
return R && isCheckedPtrCapable(R);
249+
return R ? isCheckedPtrCapable(R) : std::nullopt;
250250
}
251251

252252
bool isPtrCls(const clang::CXXRecordDecl *R) const final {

‎clang/test/Analysis/Checkers/WebKit/uncounted-members.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ namespace members {
3636
};
3737
}
3838

39-
4039
namespace ignore_unions {
4140
union Foo {
4241
RefCountable* a;
@@ -60,3 +59,12 @@ void foo(RefCountable* t) {
6059
}
6160

6261
} // ignore_system_header
62+
63+
namespace ignore_non_ref_countable {
64+
struct Foo {
65+
};
66+
67+
struct Bar {
68+
Foo* foo;
69+
};
70+
}

0 commit comments

Comments
 (0)
Please sign in to comment.