Author: echristo Date: Wed Mar 29 18:34:20 2017 New Revision: 299037 URL: http://llvm.org/viewvc/llvm-project?rev=299037&view=rev Log: Add the -grecord-gcc-switches option and pass the flags down on the compile unit.
Patch by Zhizhou Yang Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/test/Driver/debug-options.c Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=299037&r1=299036&r2=299037&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Mar 29 18:34:20 2017 @@ -2728,7 +2728,8 @@ void Clang::ConstructJob(Compilation &C, 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 @@ void Clang::ConstructJob(Compilation &C, // 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); Modified: cfe/trunk/test/Driver/debug-options.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=299037&r1=299036&r2=299037&view=diff ============================================================================== --- cfe/trunk/test/Driver/debug-options.c (original) +++ cfe/trunk/test/Driver/debug-options.c Wed Mar 29 18:34:20 2017 @@ -117,8 +117,18 @@ // RUN: %clang -### -c -gline-tables-only -g0 %s 2>&1 \ // RUN: | FileCheck -check-prefix=GLTO_NO %s // -// RUN: %clang -### -c -grecord-gcc-switches -gno-record-gcc-switches \ -// RUN: -gstrict-dwarf -gno-strict-dwarf %s 2>&1 \ +// RUN: %clang -### -c -grecord-gcc-switches %s 2>&1 \ +// | FileCheck -check-prefix=GRECORD %s +// RUN: %clang -### -c -gno-record-gcc-switches %s 2>&1 \ +// | FileCheck -check-prefix=GNO_RECORD %s +// RUN: %clang -### -c -grecord-gcc-switches -gno-record-gcc-switches %s 2>&1 \ +// | FileCheck -check-prefix=GNO_RECORD %s/ +// RUN: %clang -### -c -grecord-gcc-switches -o - %s 2>&1 \ +// | FileCheck -check-prefix=GRECORD_O %s +// RUN: %clang -### -c -O3 -ffunction-sections -grecord-gcc-switches %s 2>&1 \ +// | FileCheck -check-prefix=GRECORD_OPT %s +// +// RUN: %clang -### -c -gstrict-dwarf -gno-strict-dwarf %s 2>&1 \ // RUN: | FileCheck -check-prefix=GIGNORE %s // // RUN: %clang -### -c -ggnu-pubnames %s 2>&1 | FileCheck -check-prefix=GOPT %s @@ -194,6 +204,17 @@ // GLTO_NO: "-cc1" // GLTO_NO-NOT: -debug-info-kind= // +// GRECORD: "-dwarf-debug-flags" +// GRECORD: -### -c -grecord-gcc-switches +// +// GNO_RECORD-NOT: "-dwarf-debug-flags" +// GNO_RECORD-NOT: -### -c -grecord-gcc-switches +// +// GRECORD_O: "-dwarf-debug-flags" +// GRECORD_O: -### -c -grecord-gcc-switches -o - +// +// GRECORD_OPT: -### -c -O3 -ffunction-sections -grecord-gcc-switches +// // GIGNORE-NOT: "argument unused during compilation" // // GOPT: -generate-gnu-dwarf-pub-sections _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits