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

Alexey Samsonov samsonov at google.com
Tue May 29 01:10:35 PDT 2012


Author: samsonov
Date: Tue May 29 03:10:34 2012
New Revision: 157602

URL: http://llvm.org/viewvc/llvm-project?rev=157602&view=rev
Log:
Make Clang driver pass the last option from -g group to the compiler.
Leave a better fixme for different debug info flags

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=157602&r1=157601&r2=157602&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue May 29 03:10:34 2012
@@ -1839,15 +1839,22 @@
                       D.CCLogDiagnosticsFilename : "-");
   }
 
-  // Special case debug options to only pass -g to clang. This is
-  // wrong.
+  // Use the last option from "-g" group. "-gline-tables-only" is
+  // preserved, all other debug options are substituted with "-g".
+  // FIXME: We should eventually do the following:
+  //   1) collapse gdb and dwarf variations to -g (as we do now);
+  //   2) support things like -gtoggle;
+  //   3) ignore flag options like -gstrict-dwarf or -grecord-gcc-switches;
+  //   4) produce a driver error on unsupported formats
+  //      (-gstabs, -gcoff, -gvms etc.)
   Args.ClaimAllArgs(options::OPT_g_Group);
-  if (Arg *A = Args.getLastArg(options::OPT_g_Group))
-    if (!A->getOption().matches(options::OPT_g0)) {
+  if (Arg *A = Args.getLastArg(options::OPT_g_Group)) {
+    if (A->getOption().matches(options::OPT_gline_tables_only)) {
+      CmdArgs.push_back("-gline-tables-only");
+    } else if (!A->getOption().matches(options::OPT_g0)) {
       CmdArgs.push_back("-g");
     }
-  if (Args.hasArg(options::OPT_gline_tables_only))
-    CmdArgs.push_back("-gline-tables-only");
+  }
 
   Args.AddAllArgs(CmdArgs, options::OPT_ffunction_sections);
   Args.AddAllArgs(CmdArgs, options::OPT_fdata_sections);

Modified: cfe/trunk/test/Driver/debug-options.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=157602&r1=157601&r2=157602&view=diff
==============================================================================
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Tue May 29 03:10:34 2012
@@ -7,8 +7,13 @@
 // RUN: %clang -### -c -ganything %s 2>&1 | FileCheck -check-prefix=GANY %s
 // RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=GGDB %s
 // RUN: %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=GFOO %s
+// RUN: %clang -### -c -g -g0 %s 2>&1 | FileCheck -check-prefix=GG0 %s
 // RUN: %clang -### -c -gline-tables-only %s 2>&1 \
 // RUN:             | FileCheck -check-prefix=GLTO %s
+// RUN: %clang -### -c -gline-tables-only -g %s 2>&1 \
+// RUN:             | FileCheck -check-prefix=GLTO2 %s
+// RUN: %clang -### -c -gline-tables-only -g0 %s 2>&1 \
+// RUN:             | FileCheck -check-prefix=GLTO3 %s
 //
 // G: "-cc1"
 // G: "-g"
@@ -28,5 +33,18 @@
 // GFOO: "-cc1"
 // GFOO-NOT: "-g"
 //
+// GG0: "-cc1"
+// GG0-NOT: "-g"
+//
 // GLTO: "-cc1"
-// GLTO: "-g"
+// GLTO-NOT: "-g"
+// GLTO: "-gline-tables-only"
+// GLTO-NOT: "-g"
+//
+// GLTO2: "-cc1"
+// GLTO2-NOT: "-gline-tables-only"
+// GLTO2: "-g"
+// GLTO2-NOT: "-gline-tables-only"
+//
+// GLTO3: "-cc1"
+// GLTO3-NOT: "-gline-tables-only"





More information about the cfe-commits mailing list