[clang] Added support for `__has_feature(bounds_safety)` macro evaluation (PR #182994)

Yeoul Na via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 25 10:53:10 PST 2026


================
@@ -324,6 +324,7 @@ FEATURE(shadow_call_stack,
 FEATURE(tls, PP.getTargetInfo().isTLSSupported())
 FEATURE(underlying_type, LangOpts.CPlusPlus)
 FEATURE(experimental_library, LangOpts.ExperimentalLibrary)
+FEATURE(bounds_safety, LangOpts.BoundsSafety)
----------------
rapidsna wrote:

In many cases, checking whether attributes exist may be sufficient, yes. However, attributes may be available without -fbounds-safety — attributes are useful for documentation, interop, FORTIFY_SOURCE, warnings, etc., without needing full bounds safety enforcement. Therefore, checking whether an attribute is supported is not sufficient if the code needs to behave differently depending on whether -fbounds-safety is enabled — e.g., some users guard their tests with has_feature(bounds_safety) since the test may or may not trap.

https://github.com/llvm/llvm-project/pull/182994


More information about the cfe-commits mailing list