[clang] Update clang static analyzers per rename of member functions in CanMakeCheckedPtr. (PR #114636)
Ryosuke Niwa via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 1 20:41:24 PDT 2024
https://github.com/rniwa created https://github.com/llvm/llvm-project/pull/114636
The member functions that define CheckedPtr capable type is incrementCheckedPtrCount and decrementCheckedPtrCount after the rename.
>From 5675106782f0226297ea3e53fe7bca9137f710c4 Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa <rniwa at webkit.org>
Date: Fri, 1 Nov 2024 20:39:10 -0700
Subject: [PATCH] Update clang static analyzers per rename of member functions
in CanMakeCheckedPtr.
The member functions that define CheckedPtr capable type is incrementCheckedPtrCount
and decrementCheckedPtrCount after the rename.
---
.../Checkers/WebKit/PtrTypesSemantics.cpp | 2 +-
.../WebKit/UncountedCallArgsChecker.cpp | 3 ++-
.../test/Analysis/Checkers/WebKit/mock-types.h | 18 +++++++++---------
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index 46819d5ca12058..3f8fa636ee99ff 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -108,7 +108,7 @@ 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) {
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
index 1a5a7309a54f16..177c196127c7f0 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
@@ -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();
diff --git a/clang/test/Analysis/Checkers/WebKit/mock-types.h b/clang/test/Analysis/Checkers/WebKit/mock-types.h
index 8d95926e419beb..9c9326f0f11cfb 100644
--- a/clang/test/Analysis/Checkers/WebKit/mock-types.h
+++ b/clang/test/Analysis/Checkers/WebKit/mock-types.h
@@ -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; }
@@ -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; }
@@ -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();
More information about the cfe-commits
mailing list