From e941fc19642da421860601d43118e03f6de41c37 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Mon, 10 Oct 2016 21:56:20 +0000 Subject: [PATCH] [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. llvm-svn: 283810 --- clang/include/clang/Driver/Options.td | 2 +- clang/lib/Driver/Tools.cpp | 4 +++- clang/test/Driver/debug-options.c | 11 +++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 04af9ce..ee558f0 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/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/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index c1a2179..ee1aa6d 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/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/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c index 720a48d..0702811 100644 --- a/clang/test/Driver/debug-options.c +++ b/clang/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" -- 2.7.4