[clang] Add option -fstdlib-hardening= (PR #78763)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 27 12:41:45 PST 2024


================
@@ -1256,6 +1256,14 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
   if (Arg *A = Args.getLastArg(options::OPT_I_))
     D.Diag(diag::err_drv_I_dash_not_supported) << A->getAsString(Args);
 
+  if (Arg *A = Args.getLastArg(options::OPT_stdlib_hardening_EQ)) {
+    if (types::isCXX(Inputs[0].getType()) &&
----------------
MaskRay wrote:

If a project mixes C and C++, and I want to use one option, `-D_LIBCPP_HARDENING_MODE=... a.c` is totally fine while using `-fstdlib-hardening=` will cause an error. I wonder whether it's the desired behavior.

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


More information about the cfe-commits mailing list