[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)
Nick Desaulniers via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 31 09:03:26 PDT 2023
================
@@ -3618,6 +3618,30 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,
GenerateArg(Consumer, OPT_frandomize_layout_seed_EQ, Opts.RandstructSeed);
}
+static void CheckBoundsSafetyLang(InputKind IK, DiagnosticsEngine &Diags) {
+ // Currently, bounds safety is only supported for C. However, it's also
+ // possible to pass assembly files and LLVM IR through Clang, and
+ // those should be trivially supported. This is especially important because
+ // some build systems, like xcbuild and somewhat clumsy Makefiles, will pass
+ // C_FLAGS to Clang while building assembly files.
+ switch (IK.getLanguage()) {
+ case Language::Asm:
+ Diags.Report(diag::warn_bounds_safety_asm_ignored);
+ break;
----------------
nickdesaulniers wrote:
What happens if I'm compiling `-x assembler-with-cpp` (i.e. assembler that needs to be preprocessed, `.S` files)?
Does this error?
What if I'm using the preprocessor to detect if `-fbounds-safety` is supported?
```
#if __has_attribute(bidi_whatever)
mov x0, #42
#else
#error "oh no"
#endif
```
(or perhaps `__has_feature(bounds_safety)`)
https://github.com/llvm/llvm-project/pull/70480
More information about the cfe-commits
mailing list