[clang] [Driver][BoundsSafety] Add -fexperimental-bounds-safety flag (PR #70480)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 9 17:13:39 PST 2023


MaskRay wrote:

It depends whether an option leads to a warning or is silently ignored for a language that is not implemented.
Many options are silently ignored. For example, -faligned-new and -fexceptions are silently ignored.

Sometimes, it is useful report a warning/error to prevent misuses.
Say, the bounds checking feature may be extended to C++ in the future and before that, we want to discourage C++ projects adopting the option.
Therefore, this patch proposes an error. I think this is fine.

However, implementing the checking in clang/lib/Driver is much more common.
clang/lib/Frontend/CompilerInvocation.cpp has some checking, but the majority is in clang/lib/Driver.

I am not convinced by your argument that you want to catch -cc1 misuses.
A user can use -Xclang xxx or -mllvm yyy to specify a lot of stuff and most are infeasible to verify in clang/lib/Frontend/CompilerInvocation.cpp.
If a user is motivated to bypass the compiler' error checking, there is not much the compiler can do.


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


More information about the cfe-commits mailing list