Skip to content

Update clang static analyzers per rename of member functions in CanMakeCheckedPtr. #114636

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 3 commits into from
Nov 5, 2024
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
4 changes: 2 additions & 2 deletions clang/docs/analyzer/checkers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3459,8 +3459,8 @@ Raw pointers and references to an object which supports CheckedPtr or CheckedRef
.. code-block:: cpp

struct CheckableObj {
void incrementPtrCount() {}
void decrementPtrCount() {}
void incrementCheckedPtrCount() {}
void decrementCheckedPtrCount() {}
};

struct Foo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ std::optional<bool> isRefCountable(const clang::CXXRecordDecl *R) {
}

std::optional<bool> isCheckedPtrCapable(const clang::CXXRecordDecl *R) {
return isSmartPtrCompatible(R, "incrementPtrCount", "decrementPtrCount");
return isSmartPtrCompatible(R, "incrementCheckedPtrCount",
"decrementCheckedPtrCount");
}

bool isRefType(const std::string &Name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ class UncountedCallArgsChecker
auto name = safeGetName(MD);
if (name == "ref" || name == "deref")
return;
if (name == "incrementPtrCount" || name == "decrementPtrCount")
if (name == "incrementCheckedPtrCount" ||
name == "decrementCheckedPtrCount")
return;
}
auto *E = MemberCallExpr->getImplicitObjectArgument();
Expand Down
18 changes: 9 additions & 9 deletions clang/test/Analysis/Checkers/WebKit/mock-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ template <typename T> struct CheckedRef {

public:
CheckedRef() : t{} {};
CheckedRef(T &t) : t(&t) { t.incrementPtrCount(); }
CheckedRef(const CheckedRef &o) : t(o.t) { if (t) t->incrementPtrCount(); }
~CheckedRef() { if (t) t->decrementPtrCount(); }
CheckedRef(T &t) : t(&t) { t.incrementCheckedPtrCount(); }
CheckedRef(const CheckedRef &o) : t(o.t) { if (t) t->incrementCheckedPtrCount(); }
~CheckedRef() { if (t) t->decrementCheckedPtrCount(); }
T &get() { return *t; }
T *ptr() { return t; }
T *operator->() { return t; }
Expand All @@ -165,14 +165,14 @@ template <typename T> struct CheckedPtr {
CheckedPtr(T *t)
: t(t) {
if (t)
t->incrementPtrCount();
t->incrementCheckedPtrCount();
}
CheckedPtr(Ref<T> &&o)
: t(o.leakRef())
{ }
~CheckedPtr() {
if (t)
t->decrementPtrCount();
t->decrementCheckedPtrCount();
}
T *get() { return t; }
T *operator->() { return t; }
Expand All @@ -184,16 +184,16 @@ template <typename T> struct CheckedPtr {

class CheckedObj {
public:
void incrementPtrCount();
void decrementPtrCount();
void incrementCheckedPtrCount();
void decrementCheckedPtrCount();
void method();
int trivial() { return 123; }
};

class RefCountableAndCheckable {
public:
void incrementPtrCount() const;
void decrementPtrCount() const;
void incrementCheckedPtrCount() const;
void decrementCheckedPtrCount() const;
void ref() const;
void deref() const;
void method();
Expand Down
Loading