// Special case debug options to only pass -g to clang. This is
// wrong.
- if (Args.hasArg(options::OPT_g_Group))
+ Args.ClaimAllArgs(options::OPT_g_Group);
+ Arg *Garg = Args.getLastArg(options::OPT_g_Group);
+ if (Garg && Garg != Args.getLastArg(options::OPT_g0))
CmdArgs.push_back("-g");
Args.AddLastArg(CmdArgs, options::OPT_nostdinc);
--- /dev/null
+// RUN: %clang -S -v -o %t %s 2>&1 | not grep -w -- -g
+// RUN: %clang -S -v -o %t %s -g 2>&1 | grep -w -- -g
+// RUN: %clang -S -v -o %t %s -g0 2>&1 | not grep -w -- -g
+// RUN: %clang -S -v -o %t %s -g -g0 2>&1 | not grep -w -- -g
+// RUN: %clang -S -v -o %t %s -g0 -g 2>&1 | grep -w -- -g