[BoundsSafety] Switch new bounds checks on by default and adjust testsuite #10619
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This makes clang behave as if
-fbounds-safety-bringup-missing-checks=batch_0
was passed by default. This enables all the new bounds check in thebatch_0
group by default (which is currently all of them).Making this change broke a lot of tests. To handle this the following strategy was taken:
clang/test/BoundsSafety-legacy-checks
directory has been created and all the tests that failed have been copied into this directory. This directory has alit.local.cfg.py
file that means the%clang_cc1
substitution contains-fno-bounds-safety-bringup-missing-checks=all
. Doing that means all tests under this directory build with the new bounds checks disabled implicitly which means the copies of the tests didn't need modification to pass. We can delete this directory when we drop support for the legacy bounds checks.clang/test/BoundsSafety
have been modified to pass with the new bounds checks enabled. Note I've not removed use of-fbounds-safety-bringup-missing-checks=
under this test directory. This is something we should do as a separate clean up step.This strategy means we haven't lost any test coverage and we have gained much more test coverage for the new bounds checks.
Unfortunately while doing this I discovered that enabling the new bounds checks breaks the experimental C++ support (see
BoundsSafety/AST/value-dependence.cpp
andBoundsSafety/Sema/value-dependence.cpp
) (rdar://150044760). Given that this feature isn't currently adopted this seems acceptable and is something we can fix later if we need to.Unfortunately I also discovered that
clang/test/BoundsSafety/CodeGen/unique-trap-blocks-O2.c
is broken. I've XFAIL-ed the test and we'll need to fix a separate patch (rdar://150559639).rdar://148623233