26 Commits

Author SHA1 Message Date
Ryosuke Niwa
5c20891b2b
[WebKit Checkers] Allow a guardian CheckedPtr/CheckedRef (#110222)
This PR makes WebKit checkers allow a guardian variable which is
CheckedPtr or CheckedRef as in addition to RefPtr or Ref.
2024-10-25 08:52:56 -07:00
Ryosuke Niwa
39a91413c3
isUncountedPtr should take QualType as an argument. (#110213)
Make isUncountedPtr take QualType as an argument instead of Type*. This
simplifies some code.
2024-10-10 10:02:07 -07:00
Ryosuke Niwa
ff8a9921ec
WebKit Checkers should set DeclWithIssue. (#109389)
Set DeclWithIssue in alpha.webkit.UncountedCallArgsChecker and
alpha.webkit.UncountedLocalVarsChecker.
2024-09-27 00:02:59 -07:00
Ryosuke Niwa
91ec9cb960
[alpha.webkit.UncountedCallArgsChecker] Use canonical type (#109393)
This PR fixes a bug in UncountedCallArgsChecker that calling a function
with a member variable which is Ref/RefPtr is erroneously treated as
safe by canoniclizing the type before checking whether it's ref counted
or not.
2024-09-26 22:18:07 -07:00
Ryosuke Niwa
b06954a5d0
[alpha.webkit.UncountedCallArgsChecker] Allow protector functions in Objective-C++ (#108184)
This PR fixes the bug that WebKit checkers didn't recognize the return
value of an Objective-C++ selector which returns Ref or RefPtr to be
safe.
2024-09-11 12:06:04 -07:00
Ryosuke Niwa
21be818223
[analyzer] Support determining origins in a conditional operator in WebKit checkers. (#91143)
This PR adds the support for determining the origin of a pointer in a
conditional operator.

Because such an expression can have two distinct origins each of which
needs to be visited, this PR refactors tryToFindPtrOrigin to take a
callback instead of returning a pair.

The callback is called for the second operand and the third operand of
the conditioanl operator (i.e. E2 and E3 in E1 ? E2 : E3).

Also treat nullptr and integer literal as safe pointer origins in the
local variable checker.
2024-05-09 21:32:28 -07:00
Ryosuke Niwa
bb01b89cda
[analyzer] Ignore system headers in WebKit checkers. (#91103) 2024-05-07 19:10:50 -07:00
Ryosuke Niwa
df91cde4da
[alpha.webkit.UncountedCallArgsChecker] Ignore methods of WTF String classes. (#90704) 2024-05-01 20:29:25 -07:00
Ryosuke Niwa
3684a38d33
Revert "[alpha.webkit.UncountedCallArgsChecker] Ignore methods of WTF String classes." (#90701)
Reverts llvm/llvm-project#90180
2024-04-30 21:51:45 -07:00
Ryosuke Niwa
240592a772
[alpha.webkit.UncountedCallArgsChecker] Ignore methods of WTF String classes. (#90180) 2024-04-30 21:12:52 -07:00
Ryosuke Niwa
e441363f7d
Fix a crash introduced by 3d5e9ab by adding a nullptr check. (#90301) 2024-04-29 09:27:01 -07:00
Ryosuke Niwa
3d5e9ab6d8
[alpha.webkit.UncountedCallArgsChecker] Avoid emitting warnings for Ref, RefPtr, and their variants. (#90153)
Skip the analysis of Ref, RefPtr, and their variant classes in
UncountedCallArgsChecker since these classes are "trusted" to not do
anything dangerous.
2024-04-26 14:28:27 -07:00
Ryosuke Niwa
031f9f3317
[alpha.webkit.UncountedCallArgsChecker] Ignore calls to WTF's container methods (#82156)
This PR makes the checker ignore / skip calls to methods of Web Template
Platform's container types such as HashMap, HashSet, WeakHashSet,
WeakHashMap, Vector, etc...
2024-02-20 17:12:24 -08:00
Ryosuke Niwa
c3b87a8810
[alpha.webkit.UncountedCallArgsChecker] Allow ASSERT and atomic<T> operations in a trivial function (#82063) 2024-02-19 16:11:49 -08:00
Ryosuke Niwa
a7982d5e7a
[analyzer] UncountedCallArgsChecker: Detect & ignore trivial function calls. (#81808)
This PR introduces the concept of a "trivial function" which applies to
a function that only calls other trivial functions and contain literals
and expressions that don't result in heap mutations (specifically it
does not call deref). This is implemented using ConstStmtVisitor and
checking each statement and expression's trivialness.

This PR also introduces the concept of a "ingleton function", which is a
static member function or a free standing function which ends with the
suffix "singleton". Such a function's return value is understood to be
safe to call any function with.
2024-02-14 18:46:30 -08:00
Ryosuke Niwa
cbdc7605ed
[analyzer] Add a few more safe functions to call. (#81532)
Added checkedDowncast, uncheckedDowncast, & toString as safe functions
to call in alpha.webkit.UncountedCallArgsChecker.
2024-02-14 14:45:29 -08:00
Ryosuke Niwa
3a49dfb28f
[analyzer] Check the safety of the object argument in a member function call. (#81400)
This PR makes alpha.webkit.UncountedCallArgsChecker eplicitly check the
safety of the object argument in a member function call. It also removes
the exemption of local variables from this checker so that each local
variable's safety is checked if it's used in a function call instead of
relying on the local variable checker to find those since local variable
checker currently has exemption for "for" and "if" statements.
2024-02-14 14:44:51 -08:00
Ryosuke Niwa
2dbfa8407e
[analyzer] Allow default arguments to be evaluated like other arguments. (#80956)
This PR aligns the evaluation of default arguments with other kinds of
arguments by extracting the expressions within them as argument values
to be evaluated.
2024-02-12 15:01:40 -08:00
Ryosuke Niwa
85507f17cf
[analyzer] Ignore assignment to Ref / RefPtr in alpha.webkit.UncountedCallArgsChecker. (#80810) 2024-02-12 14:59:14 -08:00
Kazu Hirata
651c502fc8 [clang] Stop including llvm/ADT/DenseSet.h (NFC)
Identified with clangd.
2023-11-11 22:25:48 -08:00
Ryosuke Niwa
5070c1e3b0 [analyzer] WebKit checkers: recognize dynamicDowncast as a safe function.
It can take raw pointers without triggering a warning.

Also retire the support for makeRef and makeWeakPtr as they have been removed
from WebKit.
2023-10-19 16:10:57 -07:00
Kazu Hirata
6ad0788c33 [clang] Use std::optional instead of llvm::Optional (NFC)
This patch replaces (llvm::|)Optional< with std::optional<.  I'll post
a separate patch to remove #include "llvm/ADT/Optional.h".

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-14 12:31:01 -08:00
Kazu Hirata
a1580d7b59 [clang] Add #include <optional> (NFC)
This patch adds #include <optional> to those files containing
llvm::Optional<...> or Optional<...>.

I'll post a separate patch to actually replace llvm::Optional with
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2023-01-14 11:07:21 -08:00
Kazu Hirata
d0ac215dd5 [clang] Use isa instead of dyn_cast (NFC) 2021-11-14 09:32:40 -08:00
Jan Korous
47e6851423 [Analyzer][WebKit] Use tri-state types for relevant predicates
Some of the predicates can't always be decided - for example when a type
definition isn't available. At the same time it's necessary to let
client code decide what to do about such cases - specifically we can't
just use true or false values as there are callees with
conflicting strategies how to handle this.

This is a speculative fix for PR47276.

Differential Revision: https://reviews.llvm.org/D88133
2020-09-22 21:57:24 -07:00
Jan Korous
a7eb3692e7 [Analyzer][WebKit] UncountedCallArgsChecker
Differential Revision: https://reviews.llvm.org/D77179
2020-06-15 13:53:36 -07:00