Skip to content

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed
 

‎clang/docs/analyzer/checkers.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -3442,8 +3442,8 @@ Raw pointers and references to an object which supports CheckedPtr or CheckedRef
34423442
.. code-block:: cpp
34433443
34443444
struct CheckableObj {
3445-
void incrementPtrCount() {}
3446-
void decrementPtrCount() {}
3445+
void incrementCheckedPtrCount() {}
3446+
void decrementCheckedPtrCount() {}
34473447
};
34483448
34493449
struct Foo {

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ std::optional<bool> isRefCountable(const clang::CXXRecordDecl *R) {
108108
}
109109

110110
std::optional<bool> isCheckedPtrCapable(const clang::CXXRecordDecl *R) {
111-
return isSmartPtrCompatible(R, "incrementPtrCount", "decrementPtrCount");
111+
return isSmartPtrCompatible(R, "incrementCheckedPtrCount",
112+
"decrementCheckedPtrCount");
112113
}
113114

114115
bool isRefType(const std::string &Name) {

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ class UncountedCallArgsChecker
9696
auto name = safeGetName(MD);
9797
if (name == "ref" || name == "deref")
9898
return;
99-
if (name == "incrementPtrCount" || name == "decrementPtrCount")
99+
if (name == "incrementCheckedPtrCount" ||
100+
name == "decrementCheckedPtrCount")
100101
return;
101102
}
102103
auto *E = MemberCallExpr->getImplicitObjectArgument();

‎clang/test/Analysis/Checkers/WebKit/mock-types.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ template <typename T> struct CheckedRef {
146146

147147
public:
148148
CheckedRef() : t{} {};
149-
CheckedRef(T &t) : t(&t) { t.incrementPtrCount(); }
150-
CheckedRef(const CheckedRef &o) : t(o.t) { if (t) t->incrementPtrCount(); }
151-
~CheckedRef() { if (t) t->decrementPtrCount(); }
149+
CheckedRef(T &t) : t(&t) { t.incrementCheckedPtrCount(); }
150+
CheckedRef(const CheckedRef &o) : t(o.t) { if (t) t->incrementCheckedPtrCount(); }
151+
~CheckedRef() { if (t) t->decrementCheckedPtrCount(); }
152152
T &get() { return *t; }
153153
T *ptr() { return t; }
154154
T *operator->() { return t; }
@@ -165,14 +165,14 @@ template <typename T> struct CheckedPtr {
165165
CheckedPtr(T *t)
166166
: t(t) {
167167
if (t)
168-
t->incrementPtrCount();
168+
t->incrementCheckedPtrCount();
169169
}
170170
CheckedPtr(Ref<T> &&o)
171171
: t(o.leakRef())
172172
{ }
173173
~CheckedPtr() {
174174
if (t)
175-
t->decrementPtrCount();
175+
t->decrementCheckedPtrCount();
176176
}
177177
T *get() { return t; }
178178
T *operator->() { return t; }
@@ -184,16 +184,16 @@ template <typename T> struct CheckedPtr {
184184

185185
class CheckedObj {
186186
public:
187-
void incrementPtrCount();
188-
void decrementPtrCount();
187+
void incrementCheckedPtrCount();
188+
void decrementCheckedPtrCount();
189189
void method();
190190
int trivial() { return 123; }
191191
};
192192

193193
class RefCountableAndCheckable {
194194
public:
195-
void incrementPtrCount() const;
196-
void decrementPtrCount() const;
195+
void incrementCheckedPtrCount() const;
196+
void decrementCheckedPtrCount() const;
197197
void ref() const;
198198
void deref() const;
199199
void method();

0 commit comments

Comments
 (0)
Please sign in to comment.