Skip to content

Merge webkit checker improvements #8348

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

Closed
wants to merge 2,512 commits into from

Conversation

rniwa
Copy link

@rniwa rniwa commented Mar 7, 2024

Merge WebKit checker improvement PRs: llvm#82229, llvm#82291, llvm#82209, llvm#82156, llvm#82063, llvm#81829

JDevlieghere and others added 30 commits February 12, 2024 13:47
The changed default had some affect on the test suite, though not in a
way that actually regresses functionality.
…arf-verifier-debug-str-offsets-v2

[CherryPick][DWARFVerifier] Fi x debug_str_offsets DWARF version detection (llvm#81303)
Array subscript on a const size array is not bounds-checked. The idiomatic
replacement is std::array which is bounds-safe in hardened mode of libc++.

This commit extends the fixit-producing machine to consider std::array as a
transformation target type and teaches it to handle the array subscript on const
size arrays with a trivial (empty) fixit.

(cherry picked from commit 644ac2a)
Pick fix for matrix transpose hoisting.
Update lldb to use updated swift::ASTContext API.
[Matrix] Add missing intrinsic definitions to test.
Reflection context maintains several caches for TypeInfos and TypeRefs
that also include types it got from LLDBTypeInforProvider, which reads
types from DWARF. If new DWARF is available we need to invalidate
these caches.

rdar://122432501
Turn on precise Swift compiler invocations by default
This commit brings support for debug_names in DWARFYAML. It parses YAML
and generates emits a DWARF5 Accelerator table with the following
limitations:

1. All forms must have a fixed length (zero length is also ok).
2. Hard-coded support for DWARF 5 and DWARF32.
3. The generated table does not contain a hash index

All of these limitations can be lifted in the future, but for now this
is good enough to enable testing.

(cherry picked from commit a8b4c11)
…query (llvm#79932)

This commit changes DebugNamesDWARFIndex so that it now overrides
`GetFullyQualifiedType` and attempts to use DW_IDX_parent, when
available, to speed up such queries. When this type of information is
not available, the base-class implementation is used.

With this commit, we now achieve the 4x speedups reported in [1].

[1]:
https://discourse.llvm.org/t/rfc-improve-dwarf-5-debug-names-type-lookup-parsing-speed/74151/38

(cherry picked from commit 91f4a84)
…grate/cxx-safe-buffers/std-array-fixits

[-Wunsafe-buffer-usage] Introduce std::array fixits (llvm#80084)
…issue. (llvm#79398)

There are currently a few checkers that don't fill in the bug report's
"decl-with-issue" field (typically a function in which the bug is
found).

The new attribute `[[clang::suppress]]` uses decl-with-issue to reduce
the size of the suppression source range map so that it didn't need to
do that for the entire translation unit.

I'm already seeing a few problems with this approach so I'll probably
redesign it in some point as it looks like a premature optimization. Not
only checkers shouldn't be required to pass decl-with-issue (consider
clang-tidy checkers that never had such notion), but also it's not
necessarily uniquely determined (consider leak suppressions at
allocation site).

For now I'm adding a simple stop-gap solution that falls back to
building the suppression map for the entire TU whenever decl-with-issue
isn't specified. Which won't happen in the default setup because luckily
all default checkers do provide decl-with-issue.

---------

Co-authored-by: Balazs Benics <[email protected]>
(cherry picked from commit 56e241a)
This is a follow-up for 721dd3b [analyzer] NFC: Don't regenerate
duplicate HTML reports.

Because HTMLRewriter re-runs the Lexer for syntax highlighting and macro
expansion purposes, it may get fairly expensive when the rewriter is
invoked multiple times on the same file. In the static analyzer (which
uses HTMLRewriter for HTML output mode) we only get away with this
because there are usually very few reports emitted per file. But if loud
checkers are enabled, such as `webkit.*`, this may explode in complexity
and even cause the compiler to run over the 32-bit SourceLocation
addressing limit.

This patch caches intermediate results so that re-lexing only needed to
happen once.

As the clever __COUNTER__ test demonstrates, "once" is still too many.
Ideally we shouldn't re-lex anything at all, which remains a TODO.

(cherry picked from commit 243bfed)
This accessor returns a pointer from Ref type and is therefore safe.

(cherry picked from commit 8256804)
… a false positive. (llvm#80934)

The bug was caused by isRefCountable erroneously returning false for a
class with both ref() and deref() functions defined because we were not
resetting the base paths results between looking for "ref()" and
"deref()"

(cherry picked from commit f63da47)
…ts. (llvm#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.

(cherry picked from commit 2dbfa84)
llvm#80371)

The attribute is now allowed on an assortment of declarations, to
suppress warnings related to declarations themselves, or all warnings in
the lexical scope of the declaration.

I don't necessarily see a reason to have a list at all, but it does look
as if some of those more niche items aren't properly supported by the
compiler itself so let's maintain a short safe list for now.

The initial implementation raised a question whether the attribute
should apply to lexical declaration context vs. "actual" declaration
context. I'm using "lexical" here because it results in less warnings
suppressed, which is the conservative behavior: we can always expand it
later if we think this is wrong, without breaking any existing code. I
also think that this is the correct behavior that we will probably never
want to change, given that the user typically desires to keep the
suppressions as localized as possible.

(cherry picked from commit 017675f)
…m#80347)

Covers cases where DeclRefExpr referring to a const-size array decays to a
pointer and is used "as a pointer" (e. g. passed to a pointer type
parameter).

Since std::array<T, N> doesn't implicitly convert to pointer to its element
type T* the cast needs to be done explicitly as part of the fixit
when we retrofit std::array to code that previously worked with constant
size array. std::array::data() method is used for the explicit
cast.

In terms of the fixit machine this covers the UPC(DRE) case for Array fixit strategy.
The emitted fixit inserts call to std::array::data() method similarly to
analogous fixit for Span strategy.

(cherry picked from commit e06f352)
Invalidate the reflection metadata cache when new symbols are added.
In Core files the object file may not have a *file* name but still a name.
Turns out this arch is needed by the ABI impls

rdar://121963634

Co-authored-by: Mariusz Borsa <[email protected]>
(cherry picked from commit d9c3066)
[lldb] Add lldb-dap to LLVM_DISTRIBUTION_COMPONENTS
[Sanitizers][ABI] Build ASAN shim for arm64_32 arch (llvm#81066)
medismailben and others added 25 commits March 4, 2024 11:47
…83895)

This patch addresses an oversight in `ProcessEventDataTest::SetUp`
unittest to ensure the Debugger is initialized properly.

Signed-off-by: Med Ismail Bennani <[email protected]>
[lldb/Test] Fix oversight in ProcessEventDataTest::SetUp (NFC) (llvm#83895)
…3861)

This patch should address some register parsing issue in the legacy
report format.

rdar://107210149

Signed-off-by: Med Ismail Bennani <[email protected]>
[lldb/crashlog] Fix breaking changes in textual report format (llvm#83861)
…atal_error (llvm#83655)

As per the comment in `raw_fd_ostream`'s destructor, you must call
`clear_error()` to prevent a call to `report_fatal_error()`. There's not
really a way to test this, but we did encounter it in the wild.

rdar://117347895
(cherry picked from commit c4f5993)
[DSE] Delay deleting non-memory-defs until end of DSE. (llvm#83411)
…es_cherry_picked

[LV] Allow loop interleaving for loops with low trip count. (llvm#67725)
When using MCCAS replay with the option -fcas-emit-casid-file, we would
see the error:

fatal error: caching backend error: cached output file has unknown path
<path-to-file>/file.casid

This patch fixes that issue by just having a raw_fd_ostream in the
CompilerInstance that points to the .casid file rather than having it
be one of the outputs of the CompilerInstance.

This patch also makes sure that the .casid file is written even if there
is a ResultCallback in the MachOCASWriter.

(cherry picked from commit 2cd3dc3)
In case of loads/stores from an immediate address, avoid rematerializing
the constant for every block and allow consthoist to hoist it to the
entry block.

(cherry picked from commit eceb24c)
Fix bug with -fcas-emit-casid-file during replay.
[lldb] Initialize SwiftASTContext with embedded swift feature
Before this patch, if a module fails to build because of a missing
config_macro, the user will never see the config macro warning. This
patch diagnoses this before building, and each subsequent time a module
is imported.

rdar://123921931
llvm#83641
(cherry picked from commit ee044d5)
This change got missed from the upstream commit: de3b2c2
[RISCV] Hoist immediate addresses from loads/stores (llvm#83644)
…llvm#81829)

Allow address-of operator (&), enum constant, and a reference to
constant as well as materializing temporqary expression and an
expression with cleanups to appear within a trivial function.
…er methods (llvm#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...
…rtiallyDestroyed (llvm#82209)

This PR adds the support for WebKit's RefAllowingPartiallyDestroyed and
RefPtrAllowingPartiallyDestroyed, which are smart pointer types which
may be used after the destructor had started running.
…ences within trivial statements (llvm#82229)

This PR makes alpha.webkit.UncountedLocalVarsChecker ignore raw
references and pointers to a ref counted type which appears within
"trival" statements. To do this, this PR extends TrivialFunctionAnalysis
so that it can also analyze "triviality" of statements as well as that
of functions Each Visit* function is now augmented with
withCachedResult, which is responsible for looking up and updating the
cache for each Visit* functions.

As this PR dramatically improves the false positive rate of the checker,
it also deletes the code to ignore raw pointers and references within if
and for statements.
@rniwa rniwa requested review from dcci and JDevlieghere as code owners March 7, 2024 09:38
@rniwa rniwa closed this Mar 7, 2024
@rniwa rniwa deleted the merge-webkit-checker-improvements branch March 7, 2024 09:38
@rniwa rniwa restored the merge-webkit-checker-improvements branch March 7, 2024 09:44
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.