zhizhouy updated this revision to Diff 93003. zhizhouy marked 3 inline comments as done. zhizhouy added a comment.
Checked both grecord-gcc-swtiches and gno-record-gcc-switches. Modified testcases for it. https://reviews.llvm.org/D30760 Files: lib/Driver/ToolChains/Clang.cpp test/Driver/grecord-gcc-switches.c Index: test/Driver/grecord-gcc-switches.c =================================================================== --- /dev/null +++ test/Driver/grecord-gcc-switches.c @@ -0,0 +1,13 @@ +// RUN: %clang -### -g -c -grecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=REC %s +// RUN: %clang -### -g -c -gno-record-gcc-switches %s 2>&1 | FileCheck -check-prefix=NO_REC %s +// RUN: %clang -### -g -c %s 2>&1 | FileCheck %s +int main (void) { + return 0; +} + +// REC: "-dwarf-debug-flags" +// REC: -### -g -c -grecord-gcc-switches +// NO_REC-NOT: "-dwarf-debug-flags" +// NO_REC-NOT: -### -g -c -gno-record-gcc-switches +// CHECK-NOT: "-dwarf-debug-flags" +// CHECK-NOT: -### -g -c 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,12 @@ // 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. + // By default, -gno-record-gcc-switches is set on and no recording. + if (getToolChain().UseDwarfDebugFlags() || + Args.hasFlag(options::OPT_grecord_gcc_switches, + options::OPT_gno_record_gcc_switches, false)) { ArgStringList OriginalArgs; for (const auto &Arg : Args) Arg->render(Args, OriginalArgs);
Index: test/Driver/grecord-gcc-switches.c =================================================================== --- /dev/null +++ test/Driver/grecord-gcc-switches.c @@ -0,0 +1,13 @@ +// RUN: %clang -### -g -c -grecord-gcc-switches %s 2>&1 | FileCheck -check-prefix=REC %s +// RUN: %clang -### -g -c -gno-record-gcc-switches %s 2>&1 | FileCheck -check-prefix=NO_REC %s +// RUN: %clang -### -g -c %s 2>&1 | FileCheck %s +int main (void) { + return 0; +} + +// REC: "-dwarf-debug-flags" +// REC: -### -g -c -grecord-gcc-switches +// NO_REC-NOT: "-dwarf-debug-flags" +// NO_REC-NOT: -### -g -c -gno-record-gcc-switches +// CHECK-NOT: "-dwarf-debug-flags" +// CHECK-NOT: -### -g -c 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,12 @@ // 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. + // By default, -gno-record-gcc-switches is set on and no recording. + if (getToolChain().UseDwarfDebugFlags() || + Args.hasFlag(options::OPT_grecord_gcc_switches, + options::OPT_gno_record_gcc_switches, false)) { ArgStringList OriginalArgs; for (const auto &Arg : Args) Arg->render(Args, OriginalArgs);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits