[flang-commits] [clang] [flang] [flang][Driver] Add support for -f[no-]wrapv and -f[no]-strict-overflow in the frontend (PR #110061)

Tarun Prabhu via flang-commits flang-commits at lists.llvm.org
Thu Oct 3 06:45:51 PDT 2024


================
@@ -866,6 +866,17 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
     }
   }
 
+  // -fno-strict-overflow implies -fwrapv if it isn't disabled, but
+  // -fstrict-overflow won't turn off an explicitly enabled -fwrapv.
+  if (Arg *A = Args.getLastArg(options::OPT_fwrapv, options::OPT_fno_wrapv)) {
+    if (A->getOption().matches(options::OPT_fwrapv))
+      CmdArgs.push_back("-fwrapv");
+  } else if (Arg *A = Args.getLastArg(options::OPT_fstrict_overflow,
+                                      options::OPT_fno_strict_overflow)) {
+    if (A->getOption().matches(options::OPT_fno_strict_overflow))
+      CmdArgs.push_back("-fwrapv");
+  }
+
----------------
tarunprabhu wrote:

If this code is exactly the same as it is in clang, it would be better if it is shared. In `clang/lib/Driver/ToolChains/CommonArgs.cpp`, see `handleColorDiagnosticsArgs` for a case of common argument handling functionality between clang and flang. This was done in #109210 

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


More information about the flang-commits mailing list