-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[WebKit checkers] Add the support for OSObjectPtr #159484
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,16 +129,17 @@ bool isRefType(const std::string &Name) { | |
Name == "RefPtr" || Name == "RefPtrAllowingPartiallyDestroyed"; | ||
} | ||
|
||
bool isRetainPtr(const std::string &Name) { | ||
return Name == "RetainPtr" || Name == "RetainPtrArc"; | ||
bool isRetainPtrOrOSPtr(const std::string &Name) { | ||
return Name == "RetainPtr" || Name == "RetainPtrArc" || | ||
Name == "OSObjectPtr" || Name == "OSObjectPtrArc"; | ||
} | ||
|
||
bool isCheckedPtr(const std::string &Name) { | ||
return Name == "CheckedPtr" || Name == "CheckedRef"; | ||
} | ||
|
||
bool isSmartPtrClass(const std::string &Name) { | ||
return isRefType(Name) || isCheckedPtr(Name) || isRetainPtr(Name) || | ||
return isRefType(Name) || isCheckedPtr(Name) || isRetainPtrOrOSPtr(Name) || | ||
Name == "WeakPtr" || Name == "WeakPtrFactory" || | ||
Name == "WeakPtrFactoryWithBitField" || Name == "WeakPtrImplBase" || | ||
Name == "WeakPtrImplBaseSingleThread" || Name == "ThreadSafeWeakPtr" || | ||
|
@@ -166,15 +167,17 @@ bool isCtorOfCheckedPtr(const clang::FunctionDecl *F) { | |
return isCheckedPtr(safeGetName(F)); | ||
} | ||
|
||
bool isCtorOfRetainPtr(const clang::FunctionDecl *F) { | ||
bool isCtorOfRetainPtrOrOSPtr(const clang::FunctionDecl *F) { | ||
const std::string &FunctionName = safeGetName(F); | ||
return FunctionName == "RetainPtr" || FunctionName == "adoptNS" || | ||
FunctionName == "adoptCF" || FunctionName == "retainPtr" || | ||
FunctionName == "RetainPtrArc" || FunctionName == "adoptNSArc"; | ||
FunctionName == "RetainPtrArc" || FunctionName == "adoptNSArc" || | ||
FunctionName == "adoptOSObject" || FunctionName == "adoptOSObjectArc"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Same as above - rename function to reflect the new functionality. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Renamed to |
||
} | ||
|
||
bool isCtorOfSafePtr(const clang::FunctionDecl *F) { | ||
return isCtorOfRefCounted(F) || isCtorOfCheckedPtr(F) || isCtorOfRetainPtr(F); | ||
return isCtorOfRefCounted(F) || isCtorOfCheckedPtr(F) || | ||
isCtorOfRetainPtrOrOSPtr(F); | ||
} | ||
|
||
template <typename Predicate> | ||
|
@@ -198,8 +201,8 @@ bool isRefOrCheckedPtrType(const clang::QualType T) { | |
T, [](auto Name) { return isRefType(Name) || isCheckedPtr(Name); }); | ||
} | ||
|
||
bool isRetainPtrType(const clang::QualType T) { | ||
return isPtrOfType(T, [](auto Name) { return isRetainPtr(Name); }); | ||
bool isRetainPtrOrOSPtrType(const clang::QualType T) { | ||
return isPtrOfType(T, [](auto Name) { return isRetainPtrOrOSPtr(Name); }); | ||
} | ||
|
||
bool isOwnerPtrType(const clang::QualType T) { | ||
|
@@ -273,7 +276,7 @@ bool RetainTypeChecker::isUnretained(const QualType QT, bool ignoreARC) { | |
std::optional<bool> isUnretained(const QualType T, bool IsARCEnabled) { | ||
if (auto *Subst = dyn_cast<SubstTemplateTypeParmType>(T)) { | ||
if (auto *Decl = Subst->getAssociatedDecl()) { | ||
if (isRetainPtr(safeGetName(Decl))) | ||
if (isRetainPtrOrOSPtr(safeGetName(Decl))) | ||
return false; | ||
} | ||
} | ||
|
@@ -373,7 +376,7 @@ std::optional<bool> isGetterOfSafePtr(const CXXMethodDecl *M) { | |
method == "impl")) | ||
return true; | ||
|
||
if (isRetainPtr(className) && method == "get") | ||
if (isRetainPtrOrOSPtr(className) && method == "get") | ||
return true; | ||
|
||
// Ref<T> -> T conversion | ||
|
@@ -394,7 +397,7 @@ std::optional<bool> isGetterOfSafePtr(const CXXMethodDecl *M) { | |
} | ||
} | ||
|
||
if (isRetainPtr(className)) { | ||
if (isRetainPtrOrOSPtr(className)) { | ||
if (auto *maybeRefToRawOperator = dyn_cast<CXXConversionDecl>(M)) { | ||
auto QT = maybeRefToRawOperator->getConversionType(); | ||
auto *T = QT.getTypePtrOrNull(); | ||
|
@@ -425,10 +428,10 @@ bool isCheckedPtr(const CXXRecordDecl *R) { | |
return false; | ||
} | ||
|
||
bool isRetainPtr(const CXXRecordDecl *R) { | ||
bool isRetainPtrOrOSPtr(const CXXRecordDecl *R) { | ||
assert(R); | ||
if (auto *TmplR = R->getTemplateInstantiationPattern()) | ||
return isRetainPtr(safeGetName(TmplR)); | ||
return isRetainPtrOrOSPtr(safeGetName(TmplR)); | ||
return false; | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe rename
isRetainPtr
to indicate its new functionality.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to
isRetainPtrOrOSPtr
.