[clang] [Driver][BoundsSafety] Add -fbounds-safety-experimental flag (PR #70480)

Dan Liew via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 31 14:23:47 PDT 2023


================
@@ -330,6 +330,14 @@ def warn_alias_with_section : Warning<
   "as the %select{aliasee|resolver}2">,
   InGroup<IgnoredAttributes>;
 
+let CategoryName = "Bounds Safety Issue" in {
+def err_bounds_safety_lang_not_supported : Error<
+  "bounds safety is only supported for C">;
+def warn_bounds_safety_asm_ignored : Warning<
+  "'-fbounds-safety' is ignored for assembly">,
----------------
delcypher wrote:

@MaskRay So we aren't explicit using `getLastArg` but it looks like we are calling it indirectly from `addOptInFlag(...)` which I think means we are unconditionally claiming the option.  In order to make your suggestion work we'd have to conditionally call `addOptInFlag` in the driver based on the selected input language but I don't think that's going to work because no `LangOptions` object exists for us query at that point in the driver AFAICT.

Also future patches we will upstream will add additional `Args.getLastArg(options::OPT_fbounds_safety_experimental, ...)` calls in the driver which means the option will get claimed there too which will break any reliance on the option not being claimed that might be implemented in this PR.

This warning is really a frontend warning and not a driver warning so I think we should use the frontend warning that @rapidsna introduced in this PR.

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


More information about the cfe-commits mailing list