From: Eric Christopher Date: Wed, 29 Mar 2017 23:34:20 +0000 (+0000) Subject: Add the -grecord-gcc-switches option and pass the flags down on the compile unit. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6cecba61e47d6be93136d0caaeba3d7e54962e8f;p=clang Add the -grecord-gcc-switches option and pass the flags down on the compile unit. Patch by Zhizhou Yang git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299037 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index 17c860f88d..0511004b41 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -2728,7 +2728,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, 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, const JobAction &JA, // 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); diff --git a/test/Driver/debug-options.c b/test/Driver/debug-options.c index be50ee8af7..74deb414fc 100644 --- a/test/Driver/debug-options.c +++ b/test/Driver/debug-options.c @@ -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