Skip to content

Conversation

delcypher
Copy link

In rdar://158088410
(#11455) the -funique-traps flag was removed in favor of a different implementation controlled by the -fbounds-safety-unique-traps flag.

It turns out the -funique-traps flag is being used by an adopter of -fbounds-safety. To unbreak adopters of the flag this patch reintroduces the old flag (and its negation) as an alias of
-fbounds-safety-unique-traps (-fno-bounds-safety-unique-traps) along with a diagnostic warning that -funique-traps (-fno-unique-traps) is deprecated.

This patch doesn't use the Alias<> mixin in the
clang/Driver/Options.td so "technically" at the implementation level -funique-traps isn't an alias of -fbounds-safety-unique-traps. This is done so that is possible distinguish use of the legacy flag from the new flag so that it is possible emit a deprecation warning. However, from the user's perspective -funique-traps and
-fbounds-safety-unique-traps are aliases.

We should remove -funique-traps eventually and that is tracked by rdar://162215869.

rdar://162204734

@delcypher delcypher self-assigned this Oct 9, 2025
@delcypher delcypher added the clang:bounds-safety Issue relating to the experimental -fbounds-safety feature in Clang label Oct 9, 2025
…bounds-safety-unique-traps`

In rdar://158088410
(swiftlang#11455) the
`-funique-traps` flag was removed in favor of a different implementation
controlled by the `-fbounds-safety-unique-traps` flag.

It turns out the `-funique-traps` flag is being used by an adopter of
`-fbounds-safety`. To unbreak adopters of the flag this patch reintroduces
the old flag (and its negation) as an alias of
`-fbounds-safety-unique-traps` (`-fno-bounds-safety-unique-traps`) along
with a diagnostic warning that `-funique-traps` (`-fno-unique-traps`) is
deprecated.

This patch doesn't use the `Alias<>` mixin in the
`clang/Driver/Options.td` so "technically" at the implementation level
`-funique-traps` isn't an alias of `-fbounds-safety-unique-traps`. This
is done so that is possible distinguish use of the legacy flag from the
new flag so that it is possible emit a deprecation warning. However,
from the user's perspective `-funique-traps` and
`-fbounds-safety-unique-traps` are aliases.

We should remove `-funique-traps` eventually and that is tracked by
rdar://162215869.

rdar://162204734
@delcypher delcypher force-pushed the dliew/rdar-162204734 branch from e2d33ca to 7581278 Compare October 9, 2025 00:56
@delcypher
Copy link
Author

@swift-ci test llvm

else
ReplacementArg = getDriverOptTable().getOptionName(
options::OPT_fno_bounds_safety_unique_traps);
D.Diag(diag::warn_drv_deprecated_arg)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make sure that this warning doesn't trigger as an error for the project using this flag?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we should do that but as a separate task to landing this fix here.

@delcypher
Copy link
Author

Test failures are known:

20:22:51  ********************
20:22:51  Unresolved Tests (3):
20:22:51    Clang :: Index/Store/json-with-module.m
20:22:51    Clang :: Index/Store/json-with-pch.c
20:22:51    Clang :: Index/Store/syntax-only.c
20:22:51  
20:22:51  ********************
20:22:51  Failed Tests (10):
20:22:51    Clang :: BoundsSafety/CodeGen/constant-forge-ptr-expr.c
20:22:51    Clang :: BoundsSafety/CodeGen/init-global-unsafe-forge-const.c
20:22:51    Clang :: BoundsSafety/CodeGen/unsafe_forge_constant_base.c
20:22:51    Clang :: BoundsSafety/CodeGen/wide-ptr-init-with-incomplete-array.c
20:22:51    LLVM :: Transforms/Coroutines/coro-retcon-frame-old.ll
20:22:51    LLVM :: Transforms/Coroutines/coro-retcon-once-dynamic-nocleanup.ll
20:22:51    LLVM :: Transforms/Coroutines/coro-retcon-once-dynamic.ll
20:22:51    LLVM :: Transforms/Coroutines/coro-retcon-swift-coroFrameAlloc.ll
20:22:51    LLVM :: Transforms/Coroutines/coro-split-swift_coroFrameAlloc.ll
20:22:51    LLVM :: Transforms/PhaseOrdering/X86/excessive-unrolling.ll

@delcypher delcypher merged commit 38b7776 into swiftlang:next Oct 9, 2025
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:bounds-safety Issue relating to the experimental -fbounds-safety feature in Clang

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants