forked from OSchip/llvm-project
[Driver] Honor "-gdwarf-N" at any position for assembler sources
This fixes an issue when "-gdwarf-N" switch was ignored if it was given before another debug option. Differential Revision: https://reviews.llvm.org/D96865
This commit is contained in:
parent
9dcfb95ba2
commit
a0c9ec1f5e
|
@ -981,6 +981,14 @@ static unsigned DwarfVersionNum(StringRef ArgValue) {
|
|||
.Default(0);
|
||||
}
|
||||
|
||||
// Find a DWARF format version option.
|
||||
// This function is a complementary for DwarfVersionNum().
|
||||
static const Arg *getDwarfNArg(const ArgList &Args) {
|
||||
return Args.getLastArg(options::OPT_gdwarf_2, options::OPT_gdwarf_3,
|
||||
options::OPT_gdwarf_4, options::OPT_gdwarf_5,
|
||||
options::OPT_gdwarf);
|
||||
}
|
||||
|
||||
static void RenderDebugEnablingArgs(const ArgList &Args, ArgStringList &CmdArgs,
|
||||
codegenoptions::DebugInfoKind DebugInfoKind,
|
||||
unsigned DwarfVersion,
|
||||
|
@ -3848,9 +3856,7 @@ 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, options::OPT_gdwarf);
|
||||
const Arg *GDwarfN = getDwarfNArg(Args);
|
||||
bool EmitDwarf = false;
|
||||
if (GDwarfN) {
|
||||
if (checkDebugInfoOption(GDwarfN, Args, D, TC))
|
||||
|
@ -7168,18 +7174,14 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
// Forward -g and handle debug info related flags, assuming we are dealing
|
||||
// with an actual assembly file.
|
||||
bool WantDebug = false;
|
||||
unsigned DwarfVersion = 0;
|
||||
Args.ClaimAllArgs(options::OPT_g_Group);
|
||||
if (Arg *A = Args.getLastArg(options::OPT_g_Group)) {
|
||||
if (Arg *A = Args.getLastArg(options::OPT_g_Group))
|
||||
WantDebug = !A->getOption().matches(options::OPT_g0) &&
|
||||
!A->getOption().matches(options::OPT_ggdb0);
|
||||
if (WantDebug)
|
||||
DwarfVersion = DwarfVersionNum(A->getSpelling());
|
||||
}
|
||||
|
||||
unsigned DefaultDwarfVersion = ParseDebugDefaultVersion(getToolChain(), Args);
|
||||
if (DwarfVersion == 0)
|
||||
DwarfVersion = DefaultDwarfVersion;
|
||||
unsigned DwarfVersion = ParseDebugDefaultVersion(getToolChain(), Args);
|
||||
if (const Arg *GDwarfN = getDwarfNArg(Args))
|
||||
DwarfVersion = DwarfVersionNum(GDwarfN->getSpelling());
|
||||
|
||||
if (DwarfVersion == 0)
|
||||
DwarfVersion = getToolChain().GetDefaultDwarfVersion();
|
||||
|
|
|
@ -60,3 +60,18 @@
|
|||
// GDWARF64_VER: error: invalid argument '-gdwarf64' only allowed with 'DWARFv3 or greater'
|
||||
// GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 bit architecture'
|
||||
// GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF platforms'
|
||||
|
||||
// Check that -gdwarf-N can be placed before other options of the "-g" group.
|
||||
// RUN: %clang -### -c -g -gdwarf-3 -target %itanium_abi_triple -fintegrated-as -x assembler %s 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=DWARF3 %s
|
||||
// RUN: %clang -### -c -gdwarf-3 -g -target %itanium_abi_triple -fintegrated-as -x assembler %s 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=DWARF3 %s
|
||||
// RUN: %clang -### -c -g -gdwarf-5 -target %itanium_abi_triple -fintegrated-as -x assembler %s 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=DWARF5 %s
|
||||
// RUN: %clang -### -c -gdwarf-5 -g -target %itanium_abi_triple -fintegrated-as -x assembler %s 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=DWARF5 %s
|
||||
|
||||
// DWARF3: "-cc1as"
|
||||
// DWARF3: "-dwarf-version=3"
|
||||
// DWARF5: "-cc1as"
|
||||
// DWARF5: "-dwarf-version=5"
|
||||
|
|
Loading…
Reference in New Issue