[clang] 1ff8a68 - [clang/driver] Add `-gno-modules` as the negative version of `-gmodules`
Argyrios Kyrtzidis via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 20 12:43:09 PST 2023
Author: Argyrios Kyrtzidis
Date: 2023-01-20T12:39:07-08:00
New Revision: 1ff8a687ae151df72ffd3aac534fdd0d1b39f7ca
URL: https://github.com/llvm/llvm-project/commit/1ff8a687ae151df72ffd3aac534fdd0d1b39f7ca
DIFF: https://github.com/llvm/llvm-project/commit/1ff8a687ae151df72ffd3aac534fdd0d1b39f7ca.diff
LOG: [clang/driver] Add `-gno-modules` as the negative version of `-gmodules`
Differential Revision: https://reviews.llvm.org/D142236
Added:
Modified:
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/debug-options.c
Removed:
################################################################################
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 343cc77a18c4..a100d2c3e502 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3292,6 +3292,7 @@ def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group<g_flags_Group>;
def gmodules : Flag <["-"], "gmodules">, Group<gN_Group>,
HelpText<"Generate debug info with external references to clang modules"
" or precompiled headers">;
+def gno_modules : Flag <["-"], "gno-modules">, Group<gN_Group>;
def gz_EQ : Joined<["-"], "gz=">, Group<g_flags_Group>,
HelpText<"DWARF debug sections compression type">;
def gz : Flag<["-"], "gz">, Alias<gz_EQ>, AliasArgs<["zlib"]>, Group<g_flags_Group>;
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index f766eeda3cc4..d4a0772d6149 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -4219,9 +4219,11 @@ static void renderDebugOptions(const ToolChain &TC, const Driver &D,
CmdArgs.push_back("-gno-column-info");
// FIXME: Move backend command line options to the module.
- // If -gline-tables-only or -gline-directives-only is the last option it wins.
- if (const Arg *A = Args.getLastArg(options::OPT_gmodules))
- if (checkDebugInfoOption(A, Args, D, TC)) {
+ if (Args.hasFlag(options::OPT_gmodules, options::OPT_gno_modules, false)) {
+ // If -gline-tables-only or -gline-directives-only is the last option it
+ // wins.
+ if (checkDebugInfoOption(Args.getLastArg(options::OPT_gmodules), Args, D,
+ TC)) {
if (DebugInfoKind != codegenoptions::DebugLineTablesOnly &&
DebugInfoKind != codegenoptions::DebugDirectivesOnly) {
DebugInfoKind = codegenoptions::DebugInfoConstructor;
@@ -4229,6 +4231,7 @@ static void renderDebugOptions(const ToolChain &TC, const Driver &D,
CmdArgs.push_back("-fmodule-format=obj");
}
}
+ }
if (T.isOSBinFormatELF() && SplitDWARFInlining)
CmdArgs.push_back("-fsplit-dwarf-inlining");
diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c
index 37a975da5b48..b2198ebd0a20 100644
--- a/clang/test/Driver/debug-options.c
+++ b/clang/test/Driver/debug-options.c
@@ -300,6 +300,9 @@
// RUN: %clang -### -target %itanium_abi_triple -gmodules -gline-directives-only %s 2>&1 \
// RUN: | FileCheck -check-prefix=GLIO_ONLY %s
//
+// RUN: %clang -### -gmodules -gno-modules %s 2>&1 \
+// RUN: | FileCheck -check-prefix=NOGEXTREFS %s
+//
// NOG_PS: "-cc1"
// NOG_PS-NOT: "-dwarf-version=
// NOG_PS: "-generate-arange-section"
@@ -407,6 +410,7 @@
//
// GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj"
// GEXTREFS: "-debug-info-kind={{standalone|constructor}}"
+// NOGEXTREFS-NOT: -dwarf-ext-refs
// RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck -check-prefix=BADSTRING1 %s
// BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind'
More information about the cfe-commits
mailing list