Skip to content

Commit

Permalink
DebugInfo: Let -gdwarf use the toolchain default DWARF version, inste…
Browse files Browse the repository at this point in the history
…ad of hardcoded/aliased to -gdwarf-4
  • Loading branch information
dwblaikie committed Nov 1, 2019
1 parent cecc0d2 commit 098d901
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions clang/include/clang/Driver/Options.td
Expand Up @@ -1972,6 +1972,10 @@ def ggdb2 : Flag<["-"], "ggdb2">, Group<ggdbN_Group>;
def ggdb3 : Flag<["-"], "ggdb3">, Group<ggdbN_Group>;
def glldb : Flag<["-"], "glldb">, Group<gTune_Group>;
def gsce : Flag<["-"], "gsce">, Group<gTune_Group>;
// Equivalent to our default dwarf version. Forces usual dwarf emission when
// CodeView is enabled.
def gdwarf : Flag<["-"], "gdwarf">, Group<g_Group>,
HelpText<"Generate source-level debug information with the default dwarf version">;
def gdwarf_2 : Flag<["-"], "gdwarf-2">, Group<g_Group>,
HelpText<"Generate source-level debug information with dwarf version 2">;
def gdwarf_3 : Flag<["-"], "gdwarf-3">, Group<g_Group>,
Expand All @@ -1989,10 +1993,6 @@ def gcodeview_ghash : Flag<["-"], "gcodeview-ghash">,
Flags<[CC1Option, CoreOption]>;
def gno_codeview_ghash : Flag<["-"], "gno-codeview-ghash">, Flags<[CoreOption]>;

// Equivalent to our default dwarf version. Forces usual dwarf emission when
// CodeView is enabled.
def gdwarf : Flag<["-"], "gdwarf">, Alias<gdwarf_4>, Flags<[CoreOption]>;

def gfull : Flag<["-"], "gfull">, Group<g_Group>;
def gused : Flag<["-"], "gused">, Group<g_Group>;
def gstabs : Joined<["-"], "gstabs">, Group<g_Group>, Flags<[Unsupported]>;
Expand Down
7 changes: 4 additions & 3 deletions clang/lib/Driver/ToolChains/Clang.cpp
Expand Up @@ -3198,9 +3198,9 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D,
}

// If a -gdwarf argument appeared, remember it.
const Arg *GDwarfN =
Args.getLastArg(options::OPT_gdwarf_2, options::OPT_gdwarf_3,
options::OPT_gdwarf_4, options::OPT_gdwarf_5);
const Arg *GDwarfN = Args.getLastArg(
options::OPT_gdwarf_2, options::OPT_gdwarf_3, options::OPT_gdwarf_4,
options::OPT_gdwarf_5, options::OPT_gdwarf);
bool EmitDwarf = false;
if (GDwarfN) {
if (checkDebugInfoOption(GDwarfN, Args, D, TC))
Expand Down Expand Up @@ -3231,6 +3231,7 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D,
if (EmitDwarf) {
// Start with the platform default DWARF version
DWARFVersion = TC.GetDefaultDwarfVersion();
assert(DWARFVersion && "toolchain default DWARF version must be nonzero");

// Override with a user-specified DWARF version
if (GDwarfN)
Expand Down
1 change: 1 addition & 0 deletions clang/test/CodeGen/dwarf-version.c
Expand Up @@ -14,6 +14,7 @@
// RUN: %clang -target powerpc-unknown-openbsd -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2
// RUN: %clang -target powerpc-unknown-freebsd -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2
// RUN: %clang -target i386-pc-solaris -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2
// RUN: %clang -target i386-pc-solaris -gdwarf -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2

// Check which debug info formats we use on Windows. By default, in an MSVC
// environment, we should use codeview. You can enable dwarf, which implicitly
Expand Down

0 comments on commit 098d901

Please sign in to comment.