[cfe-commits] r147819 - in /cfe/trunk: lib/Driver/Tools.cpp test/Driver/debug-options.c

Eric Christopher echristo at apple.com
Mon Jan 9 16:38:01 PST 2012


Author: echristo
Date: Mon Jan  9 18:38:01 2012
New Revision: 147819

URL: http://llvm.org/viewvc/llvm-project?rev=147819&view=rev
Log:
Add -g to the cc1as flags only if we're dealing with an original
source file. Otherwise -g -save-temps will error out on the compile
of any .c file.

Fixes about 4000 of the errors in the clang-tests gdb test suite.

Modified:
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=147819&r1=147818&r2=147819&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Jan  9 18:38:01 2012
@@ -2567,12 +2567,21 @@
   // Ignore explicit -force_cpusubtype_ALL option.
   (void) Args.hasArg(options::OPT_force__cpusubtype__ALL);
 
-  // Same as Clang::ConstructJob() we special case debug options to only pass
-  // -g to clang. I guess if it is wrong there then it is wrong here too :) .
-  Args.ClaimAllArgs(options::OPT_g_Group);
-  if (Arg *A = Args.getLastArg(options::OPT_g_Group))
-    if (!A->getOption().matches(options::OPT_g0))
-      CmdArgs.push_back("-g");
+  // Determine the original source input.
+  const Action *SourceAction = &JA;
+  while (SourceAction->getKind() != Action::InputClass) {
+    assert(!SourceAction->getInputs().empty() && "unexpected root action!");
+    SourceAction = SourceAction->getInputs()[0];
+  }
+
+  // Forward -g, assuming we are dealing with an actual assembly file.
+  if (SourceAction->getType() == types::TY_Asm ||
+      SourceAction->getType() == types::TY_PP_Asm) {
+    Args.ClaimAllArgs(options::OPT_g_Group);
+    if (Arg *A = Args.getLastArg(options::OPT_g_Group))
+      if (!A->getOption().matches(options::OPT_g0))
+        CmdArgs.push_back("-g");
+  }
 
   // Optionally embed the -cc1as level arguments into the debug info, for build
   // analysis.

Modified: cfe/trunk/test/Driver/debug-options.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=147819&r1=147818&r2=147819&view=diff
==============================================================================
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Mon Jan  9 18:38:01 2012
@@ -5,6 +5,7 @@
 // RUN: %clang -### -c -g3 %s 2>&1 | FileCheck -check-prefix=G3 %s
 // RUN: %clang -### -c -ganything %s 2>&1 | FileCheck -check-prefix=GANY %s
 // RUN: %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=GFOO %s
+// RUN: %clang -### -c -save-temps -g %s 2>&1 | FileCheck -check-prefix=SAVE %s
 //
 // G: "-cc1"
 // G: "-g"
@@ -17,3 +18,6 @@
 //
 // GFOO: "-cc1"
 // GFOO-NOT: "-g"
+//
+// SAVE: "-cc1as"
+// SAVE-NOT: "-g"





More information about the cfe-commits mailing list