-
Notifications
You must be signed in to change notification settings - Fork 341
[BoundsSafety] Add warning diagnostics for uses of legacy bounds checks #10800
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
base: next
Are you sure you want to change the base?
Conversation
What happens if you compile with |
You'll get all the checks in |
clang/test/BoundsSafety/Frontend/bounds-safety-bringup-missing-chekcs-disabled.c
Outdated
Show resolved
Hide resolved
I was thinking more along the lines of whether you still get |
Ah. That's a good point. Right now the diagnostic will say:
That is confusing but I'm not sure how best to fix that. If we suggest adding If the user's flags are currently
the right fix is not to add In general there are multiple scenarios where we can end up with bounds checks disabled
In only the last case suggesting |
871ae81
to
5ad987d
Compare
I've reworked this so now it works a lot better but I need to fix a bunch of tests that have broken because of this diagnostic. |
LangOptions::BS_CHK_None; | ||
|
||
// Loop over all batches except "none" | ||
for (size_t BatchIdx = 0; BatchIdx < BatchesAR.size() - 1; ++BatchIdx) { |
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.
Do we have plans to support more batches? Right now, we only have one batch.
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.
I have a strong hunch that we'll need more in the future so I'm including support for multiple batches.
90b234c
to
0c39cd8
Compare
@swift-ci test llvm |
Linux failures:
|
So without my changes I'm seeing these failures for macOS so these are unrelated to my change.
|
@rapidsna @hnrklssn @patrykstefanski This PR is ready for another round of reviews. |
This adds warning diagnostics when any of the new bounds checks that can be enabled with `-fbounds-safety-bringup-missing-checks=batch_0` are disabled. If all bounds checks in the batch are disabled a single diagnostic is emitted. If only some of the bounds checks in the batch are disabled then a diagnostic is emitted for each disabled bounds check. The implementation will either suggest enabling a batch of checks (e.g. `-fbounds-safety-bringup-missing-checks=batch_0`) or will suggest removing a flag that is explicitly disabling a check (e.g. `-fno-bounds-safety-bringup-missing-checks=access_size`). The current implementation supports there being multple batches of checks. However, there is currently only one batch (`batch_0`). I originally tried to emit these warnings in the frontend. Unfortunately it turns out warning suppression (i.e. `-Wno-bounds-safety-legacy-checks-enabled`) and `-Werror` don't work correctly if warnings are emitted from the frontend (rdar://152730261). To workaround this the `-fbounds-safety-bringup-missing-checks=` flags are now also parsed in the Driver and at this point (and only this point) diagnostics for missing checks are emitted. The intention is to make these warnings be errors eventually. rdar://150805550
0c39cd8
to
63069eb
Compare
@swift-ci test llvm |
This adds warning diagnostics when any of the new bounds checks that can
be enabled with
-fbounds-safety-bringup-missing-checks=batch_0
aredisabled.
If all bounds checks in the batch are disabled a single diagnostic is
emitted. If only some of the bounds checks in the batch are disabled
then a diagnostic is emitted for each disabled bounds check. The
implementation will either suggest enabling a batch of checks (e.g.
-fbounds-safety-bringup-missing-checks=batch_0
) or will suggestremoving a flag that is explicitly disabling a check (e.g.
-fno-bounds-safety-bringup-missing-checks=access_size
).The current implementation supports there being multple batches of
checks. However, there is currently only one batch (
batch_0
).I originally tried to emit these warnings in the frontend. Unfortunately
it turns out warning suppression (i.e.
-Wno-bounds-safety-legacy-checks-enabled
) and-Werror
don't workcorrectly if warnings are emitted from the frontend (rdar://152730261).
To workaround this the
-fbounds-safety-bringup-missing-checks=
flagsare now also parsed in the Driver and at this point (and only this
point) diagnostics for missing checks are emitted.
The intention is to make these warnings be errors eventually.
rdar://150805550