Skip to content

Conversation

delcypher
Copy link

@delcypher delcypher commented Sep 29, 2025

This patch introduces two new build settings

The first is CLANG_BOUNDS_SAFETY_BRINGUP_MISSING_CHECKS. This setting can be used to control which new bounds checks are enabled. It takes two special values:

  1. none - This disables all the new bounds checks. This corresponds to -fno-bounds-safety-bringup-missing-checks.
  2. default - This will use the compiler default (i.e. the build system won't pass the -fbounds-safety-bringup-missing-checks= flag).

If the build setting value is not any of the special values it is passed directly as an argument to -fbounds-safety-bringup-missing-checks=. This allows enabling a specific set of checks. E.g.:

CLANG_BOUNDS_SAFETY_BRINGUP_MISSING_CHECKS=access_size,return_size

would pass -fbounds-safety-bringup-missing-checks=access_size,return-size.

The second build setting is
CLANG_BOUNDS_SAFETY_BRINGUP_MISSING_CHECKS_OPT_OUTS. This setting is intended to complement the previous build setting by providing a way to opt out of specific bounds checks. E.g.:

CLANG_BOUNDS_SAFETY_BRINGUP_MISSING_CHECKS=batch_0
CLANG_BOUNDS_SAFETY_BRINGUP_MISSING_CHECKS_OPT_OUTS=access_size

This is equivalent to

-fbound-safety-bringup-missing-checks=batch_0 -fno-bounds-safety-bringup-missing-checks=access_size

This opts the compilation unit into all checks in the batch_0 group except the access_size bounds check.

These new build settings only apply when all of the following are true:

  • CLANG_ENABLE_BOUNDS_SAFETY or CLANG_ENABLE_BOUNDS_ATTRIBUTES is enabled.
  • For C source files

The existing boundsSafetyCLanguageExtension test case has been modified to test the behavior of these new flags.

rdar://161599307

…r `-fbounds-safety`

This patch introduces two new build settings

The first is `CLANG_BOUNDS_SAFETY_BRINGUP_MISSING_CHECKS`. This setting can be used
to control which new bounds checks are enabled. It takes two special
values:

1. `none` - This disables all the new bounds checks. This corresponds to
   `-fno-bounds-safety-bringup-missing-checks`.
2. `default` - This will use the compiler default (i.e. the build system
   won't pass the `-fbounds-safety-bringup-missing-checks=` flag).

If the build setting value is not any of the special values it is passed
directly as an argument to `-fbounds-safety-bringup-missing-checks=`.
This allows enabling a specific set of checks. E.g.:

```
CLANG_BOUNDS_SAFETY_BRINGUP_MISSING_CHECKS=access_size,return_size
```

would pass `-fbounds-safety-bringup-missing-checks=access_size,return-size`.

The second build setting is
`CLANG_BOUNDS_SAFETY_BRINGUP_MISSING_CHECKS_OPT_OUTS`. This setting is
intended to complement the previous build setting by providing a way to
opt out of specific bounds checks. E.g.:

```
CLANG_BOUNDS_SAFETY_BRINGUP_MISSING_CHECKS=batch_0
CLANG_BOUNDS_SAFETY_BRINGUP_MISSING_CHECKS_OPT_OUTS=access_size
```

This is equivalent to

```
-fbound-safety-bringup-missing-checks=batch_0 -fno-bounds-safety-bringup-missing-checks=access_size
```

This opts the compilation unit into all checks in the `batch_0` group
except the `access_size` bounds check.

These new build settings only apply when all of the following are true:

* `CLANG_ENABLE_BOUNDS_SAFETY` or `CLANG_ENABLE_BOUNDS_ATTRIBUTES` is enabled.
* For C source files

The existing `boundsSafetyCLanguageExtension` test case has been
modified to test the behavior of these new flags.

rdar://161599307
@delcypher
Copy link
Author

@swift-ci test

@delcypher
Copy link
Author

delcypher commented Sep 29, 2025

There are some CI failures. I'm not sure they are related to my PR

2025-09-29T22:11:18.5742230Z ✘ Suite ClangModuleVerifierTests failed after 661.080 seconds with 7 issues.
...
2025-09-29T22:19:56.3350560Z ✘ Suite ClangCompilationCachingTests failed after 693.104 seconds with 12 issues.

This is for the Test / macOS (Xcode 26.0 - sequoia - ARM64) configuration.

@delcypher delcypher merged commit 221f009 into swiftlang:main Sep 29, 2025
48 of 49 checks passed
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.

3 participants