From: Adrian Prantl Date: Mon, 10 Oct 2016 21:56:20 +0000 (+0000) Subject: [Driver] Let -gline-tables-only win when it comes after -gmodules. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=24a15d69fc8bff2dd1c53bd4ecf59b5b931326d2;p=clang [Driver] Let -gline-tables-only win when it comes after -gmodules. The -gmodules option is all about putting debug type info into clang modules and for line tables the type information is irrelevant, so combining these two options makes no sense. This commmit fixes the behavior to match the one documented on the clang man page: the last -g... option wins. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@283810 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 04af9ce468..ee558f0e7f 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -1344,7 +1344,7 @@ def gno_column_info : Flag<["-"], "gno-column-info">, Group, Flag def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group; def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group; def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group; -def gmodules : Flag <["-"], "gmodules">, Group, +def gmodules : Flag <["-"], "gmodules">, Group, HelpText<"Generate debug info with external references to clang modules" " or precompiled headers">; def headerpad__max__install__names : Joined<["-"], "headerpad_max_install_names">; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index c1a2179673..ee1aa6d9d7 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -4703,7 +4703,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-dwarf-column-info"); // FIXME: Move backend command line options to the module. - if (Args.hasArg(options::OPT_gmodules)) { + // If -gline-tables-only is the last option it wins. + if (DebugInfoKind != codegenoptions::DebugLineTablesOnly && + Args.hasArg(options::OPT_gmodules)) { DebugInfoKind = codegenoptions::LimitedDebugInfo; CmdArgs.push_back("-dwarf-ext-refs"); CmdArgs.push_back("-fmodule-format=obj"); diff --git a/test/Driver/debug-options.c b/test/Driver/debug-options.c index 720a48dfdb..0702811ae8 100644 --- a/test/Driver/debug-options.c +++ b/test/Driver/debug-options.c @@ -109,6 +109,15 @@ // RUN: %clang -### -gmodules %s 2>&1 \ // RUN: | FileCheck -check-prefix=GEXTREFS %s // +// RUN: %clang -### -gmodules -g %s 2>&1 \ +// RUN: | FileCheck -check-prefix=GEXTREFS %s +// +// RUN: %clang -### -gline-tables-only -gmodules %s 2>&1 \ +// RUN: | FileCheck -check-prefix=GEXTREFS %s +// +// RUN: %clang -### -gmodules -gline-tables-only %s 2>&1 \ +// RUN: | FileCheck -check-prefix=GLTO_ONLY %s +// // G: "-cc1" // G: "-debug-info-kind=limited" // @@ -131,7 +140,9 @@ // G_NO-NOT: -debug-info-kind= // // GLTO_ONLY: "-cc1" +// GLTO_ONLY-NOT: "-dwarf-ext-refs" // GLTO_ONLY: "-debug-info-kind=line-tables-only" +// GLTO_ONLY-NOT: "-dwarf-ext-refs" // // GLTO_ONLY_DWARF2: "-cc1" // GLTO_ONLY_DWARF2: "-debug-info-kind=line-tables-only"