]> granicus.if.org Git - clang/commitdiff
Don't produce debug info when given -g. Fixes PR6529.
authorRafael Espindola <rafael.espindola@gmail.com>
Sun, 7 Mar 2010 04:46:18 +0000 (04:46 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sun, 7 Mar 2010 04:46:18 +0000 (04:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97897 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Driver/clang-g-opts.c [new file with mode: 0644]

index de9bdcc1881697b39aad572e58fb0c7c28db9f71..bc521008cf7c29f3f5f9311acb21c3593dc9a380 100644 (file)
@@ -929,7 +929,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
 
   // 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);
diff --git a/test/Driver/clang-g-opts.c b/test/Driver/clang-g-opts.c
new file mode 100644 (file)
index 0000000..4dbdf61
--- /dev/null
@@ -0,0 +1,5 @@
+// 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