[PATCH] D30760: Record command lines in objects built by clang, Clang part

Zhizhou Yang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 23 17:43:07 PDT 2017


zhizhouy updated this revision to Diff 92885.
zhizhouy retitled this revision from "Record command lines in objects built by clang" to "Record command lines in objects built by clang, Clang part".
zhizhouy edited the summary of this revision.
zhizhouy added a reviewer: aprantl.
zhizhouy added a comment.

I am reusing the DwarfDebugFlags to try to solve this bug now.

DwarfDebugFlags only records the command line options for Apple Darwin and will generate DW_AT_APPLE_flags into debug info.
I decide not to touch those parts for now.

When -grecord-gcc-switches is set, I record command line options into DwarfDebugFlags no matter what ToolChain currently is.

This patch also modified LLVM side, which can be referred to: name <https://reviews.llvm.org/D31315>


https://reviews.llvm.org/D30760

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/CodeGen/debug-info-grecord-gcc-switches.c


Index: test/CodeGen/debug-info-grecord-gcc-switches.c
===================================================================
--- /dev/null
+++ test/CodeGen/debug-info-grecord-gcc-switches.c
@@ -0,0 +1,6 @@
+// RUN: %clang -g -grecord-gcc-switches -S -emit-llvm -o - %s | FileCheck %s
+int main (void) {
+  return 0;
+}
+
+// CHECK: -g -grecord-gcc-switches -S -emit-llvm
Index: lib/Driver/ToolChains/Clang.cpp
===================================================================
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2728,7 +2728,8 @@
     DwarfVersion = getToolChain().GetDefaultDwarfVersion();
   }
 
-  // We ignore flags -gstrict-dwarf and -grecord-gcc-switches for now.
+  // We ignore flag -gstrict-dwarf for now.
+  // And we handle flag -grecord-gcc-switches later with DwarfDebugFlags.
   Args.ClaimAllArgs(options::OPT_g_flags_Group);
 
   // Column info is included by default for everything except PS4 and CodeView.
@@ -4321,7 +4322,10 @@
 
   // Optionally embed the -cc1 level arguments into the debug info, for build
   // analysis.
-  if (getToolChain().UseDwarfDebugFlags()) {
+  // Also record command line arguments into the debug info if
+  // -grecord-gcc-switches options is set on.
+  if (getToolChain().UseDwarfDebugFlags() ||
+      Args.hasArg(options::OPT_grecord_gcc_switches)) {
     ArgStringList OriginalArgs;
     for (const auto &Arg : Args)
       Arg->render(Args, OriginalArgs);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30760.92885.patch
Type: text/x-patch
Size: 1449 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170324/216ae09d/attachment.bin>


More information about the cfe-commits mailing list