Skip to content

Commit

Permalink
[clang] Merge lifetimebound and GSL code paths for lifetime analysis (l…
Browse files Browse the repository at this point in the history
…lvm#104906)

In the current lifetime analysis, we have two parallel code paths: one
for lifetimebound and another for GSL. These paths perform the same
logic, both determining whether to continue visiting subexpressions.

This PR merges the two paths into a single code path. As a result, we'll
reduce the overhead by eliminating a redundant visit to subexpressions.
The change is mostly NFC (No Functional Change). The only notable
difference is that when a subexpression is visited due to either
lifetimebound or GSL, we will prioritize the lifetimebound path. This
means the final diagnostic will be -Wdangling (rather than both
`-Wdangling` and `-Wdangling-gsl`)

This might cause a slight change in behavior if the -Wdangling
diagnostic is disabled, but I think this is not a major concern since
both diagnostics are enabled by default.

Fixes llvm#93386
  • Loading branch information
hokein authored Aug 22, 2024
1 parent fab515c commit c368a72
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 149 deletions.
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ Improvements to Clang's diagnostics

- Clang now diagnoses when the result of a [[nodiscard]] function is discarded after being cast in C. Fixes #GH104391.

- Don't emit duplicated dangling diagnostics. (#GH93386).

Improvements to Clang's time-trace
----------------------------------

Expand Down
Loading

0 comments on commit c368a72

Please sign in to comment.