[cfe-commits] r172758 - in /cfe/trunk: include/clang/Driver/CC1AsOptions.td lib/Driver/Tools.cpp test/Driver/darwin-debug-flags.c test/Driver/debug-options-as.c tools/driver/cc1as_main.cpp

Kevin Enderby enderby at apple.com
Thu Jan 17 13:38:06 PST 2013


Author: enderby
Date: Thu Jan 17 15:38:06 2013
New Revision: 172758

URL: http://llvm.org/viewvc/llvm-project?rev=172758&view=rev
Log:
We want the dwarf AT_producer for assembly source files to match clang's
AT_producer.  Which includes clang's version information so we can tell
which version of the compiler was used.

This is second of the two steps to allow us to do this.  The first was a
change to llvm-mc with revision 172630 to provide a method to set the
AT_producer string.  This second step has the clang driver passing the value
of getClangFullVersion() via the new flag -dwarf-debug-producer when invoking
the integrated assembler on assembly source files.  Then using the new
setDwarfDebugProducer() method to set the AT_producer string.

rdar://12888242

Modified:
    cfe/trunk/include/clang/Driver/CC1AsOptions.td
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Driver/darwin-debug-flags.c
    cfe/trunk/test/Driver/debug-options-as.c
    cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/include/clang/Driver/CC1AsOptions.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1AsOptions.td?rev=172758&r1=172757&r2=172758&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1AsOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CC1AsOptions.td Thu Jan 17 15:38:06 2013
@@ -93,3 +93,6 @@
 
 def dwarf_debug_flags : Separate<["-"], "dwarf-debug-flags">,
   HelpText<"The string to embed in the Dwarf debug flags record.">;
+
+def dwarf_debug_producer : Separate<["-"], "dwarf-debug-producer">,
+  HelpText<"The string to embed in the Dwarf debug AT_producer record.">;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=172758&r1=172757&r2=172758&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Jan 17 15:38:06 2013
@@ -12,6 +12,7 @@
 #include "SanitizerArgs.h"
 #include "ToolChains.h"
 #include "clang/Basic/ObjCRuntime.h"
+#include "clang/Basic/Version.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Arg.h"
 #include "clang/Driver/ArgList.h"
@@ -3341,6 +3342,11 @@
 
     // Add the -fdebug-compilation-dir flag if needed.
     addDebugCompDirArg(Args, CmdArgs);
+
+    // Set the AT_producer to the clang version when using the integrated
+    // assembler on assembly source files.
+    CmdArgs.push_back("-dwarf-debug-producer");
+    CmdArgs.push_back(Args.MakeArgString(getClangFullVersion()));
   }
 
   // Optionally embed the -cc1as level arguments into the debug info, for build

Modified: cfe/trunk/test/Driver/darwin-debug-flags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-debug-flags.c?rev=172758&r1=172757&r2=172758&view=diff
==============================================================================
--- cfe/trunk/test/Driver/darwin-debug-flags.c (original)
+++ cfe/trunk/test/Driver/darwin-debug-flags.c Thu Jan 17 15:38:06 2013
@@ -2,6 +2,8 @@
 // <rdar://problem/7256886>
 // RUN: touch %t.s
 // RUN: env RC_DEBUG_OPTIONS=1 %clang -### -target i386-apple-darwin9 -c -g %t.s 2>&1 | FileCheck -check-prefix=S %s
+// <rdar://problem/12955296>
+// RUN: %clang -### -target i386-apple-darwin9 -c -g %t.s 2>&1 | FileCheck -check-prefix=P %s
 
 // CHECK: !0 = metadata !{
 // CHECK: -g -Os
@@ -11,3 +13,5 @@
 int x;
 
 // S: "-dwarf-debug-flags"
+
+// P: "-dwarf-debug-producer"

Modified: cfe/trunk/test/Driver/debug-options-as.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options-as.c?rev=172758&r1=172757&r2=172758&view=diff
==============================================================================
--- cfe/trunk/test/Driver/debug-options-as.c (original)
+++ cfe/trunk/test/Driver/debug-options-as.c Thu Jan 17 15:38:06 2013
@@ -18,3 +18,12 @@
 //
 // CHECK: "-cc1as"
 // CHECK: "-g"
+
+// Check to make sure clang with -g on a .s file gets passed -dwarf-debug-producer.
+// rdar://12955296
+// RUN: touch %t.s
+// RUN: %clang -### -c -integrated-as -g %t.s 2>&1 \
+// RUN:   | FileCheck -check-prefix=P %s
+//
+// P: "-cc1as"
+// P: "-dwarf-debug-producer"

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=172758&r1=172757&r2=172758&view=diff
==============================================================================
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Thu Jan 17 15:38:06 2013
@@ -83,6 +83,7 @@
   unsigned SaveTemporaryLabels : 1;
   unsigned GenDwarfForAssembly : 1;
   std::string DwarfDebugFlags;
+  std::string DwarfDebugProducer;
   std::string DebugCompilationDir;
   std::string MainFileName;
 
@@ -183,6 +184,7 @@
   Opts.SaveTemporaryLabels = Args->hasArg(OPT_L);
   Opts.GenDwarfForAssembly = Args->hasArg(OPT_g);
   Opts.DwarfDebugFlags = Args->getLastArgValue(OPT_dwarf_debug_flags);
+  Opts.DwarfDebugProducer = Args->getLastArgValue(OPT_dwarf_debug_producer);
   Opts.DebugCompilationDir = Args->getLastArgValue(OPT_fdebug_compilation_dir);
   Opts.MainFileName = Args->getLastArgValue(OPT_main_file_name);
 
@@ -309,6 +311,8 @@
     Ctx.setGenDwarfForAssembly(true);
   if (!Opts.DwarfDebugFlags.empty())
     Ctx.setDwarfDebugFlags(StringRef(Opts.DwarfDebugFlags));
+  if (!Opts.DwarfDebugProducer.empty())
+    Ctx.setDwarfDebugProducer(StringRef(Opts.DwarfDebugProducer));
   if (!Opts.DebugCompilationDir.empty())
     Ctx.setCompilationDir(Opts.DebugCompilationDir);
   if (!Opts.MainFileName.empty())





More information about the cfe-commits mailing list