[clang] [Clang] Enable -fextend-lifetimes at -Og (PR #118026)

Stephen Tozer via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 12 08:16:13 PST 2024


================
@@ -1834,6 +1834,14 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
     Opts.setInlining(CodeGenOptions::NormalInlining);
   }
 
+  // If we have specified -Og and have not explicitly set -fno-extend-lifetimes,
+  // then default to -fextend-lifetimes.
+  if (Arg *A = Args.getLastArg(options::OPT_O_Group);
+      A && A->containsValue("g")) {
----------------
SLTozer wrote:

I've moved this behaviour to the driver now. Also regarding the first request to use `A->getValue() == "g"` - if just `-O` is passed then `A->getValue()` will crash, as there are no values. An alternative would be to change the check to `A->getNumValues() && A->getValue() == "g"`, but I think `containsValue` is more concise.

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


More information about the cfe-commits mailing list