Skip to content

Commit 43975f2

Browse files
committed
Introduce isCtorOfSafePtr and delete unused declaration for isRefType.
1 parent a89a4d8 commit 43975f2

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ bool tryToFindPtrOrigin(
6060
if (StopAtFirstRefCountedObj) {
6161
if (auto *ConversionFunc =
6262
dyn_cast_or_null<FunctionDecl>(cast->getConversionFunction())) {
63-
if (isCtorOfRefCounted(ConversionFunc) ||
64-
isCtorOfCheckedPtr(ConversionFunc))
63+
if (isCtorOfSafePtr(ConversionFunc))
6564
return callback(E, true);
6665
}
6766
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ bool isCtorOfCheckedPtr(const clang::FunctionDecl *F) {
140140
return isCheckedPtr(safeGetName(F));
141141
}
142142

143+
bool isCtorOfSafePtr(const clang::FunctionDecl *F) {
144+
return isCtorOfRefCounted(F) || isCtorOfCheckedPtr(F);
145+
}
146+
143147
bool isSafePtrType(const clang::QualType T) {
144148
QualType type = T;
145149
while (!type.isNull()) {

clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,20 @@ bool isSafePtrType(const clang::QualType T);
7171
/// false if not.
7272
bool isCtorOfRefCounted(const clang::FunctionDecl *F);
7373

74-
/// \returns true if \p F creates ref-countable object from uncounted parameter,
74+
/// \returns true if \p F creates checked ptr object from uncounted parameter,
7575
/// false if not.
7676
bool isCtorOfCheckedPtr(const clang::FunctionDecl *F);
7777

78+
/// \returns true if \p F creates ref-countable or checked ptr object from
79+
/// uncounted parameter, false if not.
80+
bool isCtorOfSafePtr(const clang::FunctionDecl *F);
81+
7882
/// \returns true if \p Name is RefPtr, Ref, or its variant, false if not.
7983
bool isRefType(const std::string &Name);
8084

8185
/// \returns true if \p Name is CheckedRef or CheckedPtr, false if not.
8286
bool isCheckedPtr(const std::string &Name);
8387

84-
/// \returns true if \p T is RefPtr, Ref, or its variant, false if not.
85-
bool isRefType(const clang::QualType T);
86-
8788
/// \returns true if \p M is getter of a ref-counted class, false if not.
8889
std::optional<bool> isGetterOfSafePtr(const clang::CXXMethodDecl *Method);
8990

0 commit comments

Comments
 (0)