Skip to content

Commit 853d60e

Browse files
committed
[clang] Remove -g[no-]-* bool flags from g_Group
There are four uses of BoolGOption, and all of them are essentially debug info feature flags, which I believe should not the enablement or disablement of all debug info emission. `OPT_g_group` is used to control the debug info level here: https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/Clang.cpp#L4387 This doesn't cause any test failures, and seems like the right behavior for all four flags: * -g[no-]flag-base * -g[no-]inline-line-tables * -g[no-]key-instructions * -g[no-]structor-decl-linkage-names None of these, even in the positive form, should enable debug info emission. Fixes #162747
1 parent c52de9a commit 853d60e

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,15 +545,16 @@ multiclass BoolFOption<string flag_base, KeyPathAndMacro kpm,
545545
Group<f_Group>;
546546
}
547547

548-
// Creates a BoolOption where both of the flags are prefixed with "g" and have
549-
// the Group<g_Group>.
548+
// Creates a BoolOption where both of the flags are prefixed with "g".
549+
// Does *not* map to g_Group, because that is reserved for flags that are
550+
// intended to enable (or disable) debug info, which is not appropriate for a
551+
// negative boolean flag (-gno-${feature}).
550552
// Used for -cc1 frontend options. Driver-only options do not map to
551553
// CompilerInvocation.
552554
multiclass BoolGOption<string flag_base, KeyPathAndMacro kpm,
553555
Default default, FlagDef flag1, FlagDef flag2,
554556
BothFlags both = BothFlags<[]>> {
555-
defm NAME : BoolOption<"g", flag_base, kpm, default, flag1, flag2, both>,
556-
Group<g_Group>;
557+
defm NAME : BoolOption<"g", flag_base, kpm, default, flag1, flag2, both>;
557558
}
558559

559560
multiclass BoolMOption<string flag_base, KeyPathAndMacro kpm,

clang/test/DebugInfo/KeyInstructions/flag.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
// RUN: %clang -### -target x86_64 -c -gdwarf -gkey-instructions %s 2>&1 | FileCheck %s --check-prefixes=KEY-INSTRUCTIONS
22
// RUN: %clang -### -target x86_64 -c -gdwarf -gno-key-instructions %s 2>&1 | FileCheck %s --check-prefixes=NO-KEY-INSTRUCTIONS
3+
// RUN: %clang -### -target x86_64 -c -gno-key-instructions %s 2>&1 | FileCheck %s --check-prefixes=NO-DEBUG
34

45
//// Help.
56
// RUN %clang --help | FileCheck %s --check-prefix=HELP
67
// HELP: -gkey-instructions Enable Key Instructions, which reduces the jumpiness of debug stepping in optimized C/C++ code in some debuggers. DWARF only. Implies -g.
78

89
// KEY-INSTRUCTIONS: "-gkey-instructions"
910
// NO-KEY-INSTRUCTIONS-NOT: key-instructions
11+
// NO-DEBUG-NOT: debug-info-kind
12+
// NO-DEBUG-NOT: dwarf
1013

1114
//// Help hidden: flag should not be visible.
1215
// RUN: %clang --help | FileCheck %s --check-prefix=HELP

clang/test/Driver/debug-options.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,11 @@
268268
// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=NORNGBSE %s
269269
// RUN: %clang -### -c -fdebug-ranges-base-address -fno-debug-ranges-base-address %s 2>&1 | FileCheck -check-prefix=NORNGBSE %s
270270
//
271-
// RUN: %clang -### -c -gomit-unreferenced-methods -fno-standalone-debug %s 2>&1 | FileCheck -check-prefix=INCTYPES %s
271+
// RUN: %clang -### -c -g -gomit-unreferenced-methods -fno-standalone-debug %s 2>&1 | FileCheck -check-prefix=INCTYPES %s
272272
// RUN: %clang -### -c %s 2>&1 | FileCheck -check-prefix=NOINCTYPES %s
273-
// RUN: %clang -### -c -gomit-unreferenced-methods -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 \
273+
// RUN: %clang -### -c -g -gomit-unreferenced-methods -fdebug-types-section -target x86_64-unknown-linux %s 2>&1 \
274274
// RUN: | FileCheck -check-prefix=NOINCTYPES %s
275-
// RUN: %clang -### -c -gomit-unreferenced-methods -fstandalone-debug %s 2>&1 | FileCheck -check-prefix=NOINCTYPES %s
275+
// RUN: %clang -### -c -g -gomit-unreferenced-methods -fstandalone-debug %s 2>&1 | FileCheck -check-prefix=NOINCTYPES %s
276276
//
277277
// RUN: %clang -### -c -glldb %s 2>&1 | FileCheck -check-prefix=NOPUB %s
278278
// RUN: %clang -### -c -glldb -gno-pubnames %s 2>&1 | FileCheck -check-prefix=NOPUB %s

0 commit comments

Comments
 (0)