Skip to content
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

Merge Webkit checker fixes #10219

Open
wants to merge 22 commits into
base: stable/20240723
Choose a base branch
from
Open

Conversation

rniwa
Copy link

@rniwa rniwa commented Mar 11, 2025

Merge all the WebKit checker fixes landed after #10038.

rniwa and others added 6 commits March 11, 2025 00:51
…iables to NS and CF types. (llvm#127554)

This PR adds alpha.webkit.UnretainedLocalVarsChecker by generalizing
RawPtrRefLocalVarsChecker. It checks local variables to NS or CF types
are guarded with a RetainPtr or not. The new checker is effective for NS
and CF types in Objective-C++ code without ARC, and it's effective for
CF types in code with ARC.
…gsChecker (llvm#129424)

Simply add awareness of BindingDecl to the logic for identifying local
assignments.
…uctExpr as a safe origin. (llvm#130258)

Handle CXXUnresolvedConstructExpr in tryToFindPtrOrigin so that
constructing Ref, RefPtr, CheckedRef, CheckedPtr, ... constructed in
such a way that its type is unresolved at AST level will be still
treated as a safe pointer origin.

Also fix a bug in isPtrOfType that it was not recognizing
DeducedTemplateSpecializationType.
…or lambda capturing NS or CF types. (llvm#128651)

Add a new WebKit checker for checking that lambda captures of CF types
use RetainPtr either when ARC is disabled or enabled, and those of NS
types use RetainPtr when ARC is disabled.
… unretained member variables and ivars. (llvm#128641)

Add a new WebKit checker for member variables and instance variables of
NS and CF types. A member variable or instance variable to a CF type
should be RetainPtr regardless of whether ARC is enabled or disabled,
and that of a NS type should be RetainPtr when ARC is disabled.
Prior to this PR, WebKit checkers erroneously treated functions to be
safe if it has a trivial body even if it was marked as virtual. In the
case of a virtual function, it can have an override which does not pass
the triviality check so we must not make such an assumption.

This PR also restricts the allowed operator overloading while finding
the pointer origin to just operators on smart pointer types: Ref,
RefPtr, CheckedRef, CheckedPtr, RetainPtr, WeakPtr, WeakRef, unique_ptr,
and UniqueRef.
@rniwa rniwa requested a review from a team as a code owner March 11, 2025 08:30
rniwa added 2 commits March 12, 2025 12:12
…This) (llvm#130925)

In WebKit, it's a common pattern for a lambda to capture "this" along
with "protectedThis" of Ref/RefPtr type, and re-capture "this" and
"std::move(protectedThis)" for a nested inner lambda. Recognize this
pattern and treat it as safe.
rniwa added 14 commits March 12, 2025 21:11
…n of Ref from a Ref return value safe. (llvm#130911)

Fix a bug that an explicit construction of Ref out of a Ref return value
would not be treated as safe. It is definitely safe albit redundant.
…ker for correct use of RetainPtr, adoptNS, and adoptCF (llvm#128679)

Add a new WebKit checker to validate the correct use of RetainPtr
constructor as well as adoptNS and adoptCF functions. adoptNS and
adoptCf are used for +1 semantics and RetainPtr constructor is used for
+0 semantics.
…d declarations (llvm#130554)

Add a new static analyzer which emits warnings for function call
arguments, local variables, and member variables that are only forward
declared. These forward declaration prevents other WebKit checkers from
checking the safety of code.
…eated as safe. (llvm#131500)

…os_log functions should be treated as safe in call arguments checkers.

Also treat __builtin_* functions and __libcpp_verbose_abort functions as
"trivial" for the purpose in call argument checkers.
…s treated as if it's ref countable. (llvm#131249)

This PR fixes a regression that webkit.NoUncountedMemberChecker and
alpha.webkit.NoUncheckedMemberChecker emits warnings for every class as
if they supported ref counting and checked ptr because we were
erroneously coercing the return value of isRefCountable and
isCheckedPtrCapable, which is std::optional<bool>, to boolean values.
…ase. (llvm#132497)

This PR adds the support for WTF::NoVirtualDestructorBase, which
signifies to the checker that the class is exempt from having a virtual
destructor.
…ctions. (llvm#132784)

Recognize dynamic_objc_cast, checked_objc_cast, dynamic_cf_cast, and
checked_cf_cast.
…ive-C types in ivars. (llvm#132833)

This PR fixes the bug that we weren't generating warnings when a raw
poiner is used to point to a NS type in Objective-C ivars. Also fix the
bug that we weren't suppressing this warning in system headers.
… ivar / property of a forward declared type (llvm#133755)

Prior to this PR, we were emitting warnings for Objective-C ivars and
properties if the forward declaration of the type appeared first in a
non-system header. This PR fixes the checker so tha we'd ignore ivars
and properties defined for a forward declared type.
…llvm#133605)

Objective-C selectors are supposed to return autoreleased object. Treat
these return values as safe.
…vm#133804)

There are some system libraries such as sqlite3 which forward declare a
struct then use a pointer to that forward declared type in various APIs.
Ignore these types ForwardDeclChecker like other pointer types.
…iteral as +1 (llvm#132350)

This PR adds the support for recognizing the return value of copy /
mutableCopy as +1. isAllocInit and isOwned now traverses
PseudoObjectExpr to its last semantic expression.
…otectedSelf (llvm#132518)

This PR adds the support for treating capturing of "self" as safe if the
lambda simultaneously captures "protectedSelf", which is a RetainPtr of
"self".

This PR also fixes a bug that the checker wasn't generating a warning
when "self" is implicitly captured. Note when "self" is implicitly
captured, we use the lambda's getBeginLoc as a fallback source location.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants