Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Driver/ToolChains/Clang.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 3,744 Lines • ▼ Show 20 Lines | static void RenderDebugOptions(const ToolChain &TC, const Driver &D, | ||||
// codeview if not running in a Windows environment. Perhaps even that | // codeview if not running in a Windows environment. Perhaps even that | ||||
// decision should be made in the driver as well though. | // decision should be made in the driver as well though. | ||||
llvm::DebuggerKind DebuggerTuning = TC.getDefaultDebuggerTuning(); | llvm::DebuggerKind DebuggerTuning = TC.getDefaultDebuggerTuning(); | ||||
bool SplitDWARFInlining = | bool SplitDWARFInlining = | ||||
Args.hasFlag(options::OPT_fsplit_dwarf_inlining, | Args.hasFlag(options::OPT_fsplit_dwarf_inlining, | ||||
options::OPT_fno_split_dwarf_inlining, false); | options::OPT_fno_split_dwarf_inlining, false); | ||||
Args.ClaimAllArgs(options::OPT_g_Group); | if (const Arg *A = Args.getLastArg(options::OPT_g_Group)) { | ||||
Arg* SplitDWARFArg; | Arg *SplitDWARFArg; | ||||
DwarfFission = getDebugFissionKind(D, Args, SplitDWARFArg); | DwarfFission = getDebugFissionKind(D, Args, SplitDWARFArg); | ||||
if (DwarfFission != DwarfFissionKind::None && | if (DwarfFission != DwarfFissionKind::None && | ||||
!checkDebugInfoOption(SplitDWARFArg, Args, D, TC)) { | !checkDebugInfoOption(SplitDWARFArg, Args, D, TC)) { | ||||
DwarfFission = DwarfFissionKind::None; | DwarfFission = DwarfFissionKind::None; | ||||
SplitDWARFInlining = false; | SplitDWARFInlining = false; | ||||
} | } | ||||
if (const Arg *A = | |||||
Args.getLastArg(options::OPT_g_Group, options::OPT_gsplit_dwarf, | |||||
options::OPT_gsplit_dwarf_EQ)) { | |||||
DebugInfoKind = codegenoptions::LimitedDebugInfo; | DebugInfoKind = codegenoptions::LimitedDebugInfo; | ||||
// If the last option explicitly specified a debug-info level, use it. | // If the last option explicitly specified a debug-info level, use it. | ||||
if (checkDebugInfoOption(A, Args, D, TC) && | if (checkDebugInfoOption(A, Args, D, TC) && | ||||
A->getOption().matches(options::OPT_gN_Group)) { | A->getOption().matches(options::OPT_gN_Group)) { | ||||
DebugInfoKind = DebugLevelToInfoKind(*A); | DebugInfoKind = DebugLevelToInfoKind(*A); | ||||
// For -g0 or -gline-tables-only, drop -gsplit-dwarf. This gets a bit more | // For -g0 or -gline-tables-only, drop -gsplit-dwarf. This gets a bit more | ||||
// complicated if you've disabled inline info in the skeleton CUs | // complicated if you've disabled inline info in the skeleton CUs | ||||
// (SplitDWARFInlining) - then there's value in composing split-dwarf and | // (SplitDWARFInlining) - then there's value in composing split-dwarf and | ||||
// line-tables-only, so let those compose naturally in that case. | // line-tables-only, so let those compose naturally in that case. | ||||
if (DebugInfoKind == codegenoptions::NoDebugInfo || | if (DebugInfoKind == codegenoptions::NoDebugInfo || | ||||
DebugInfoKind == codegenoptions::DebugDirectivesOnly || | DebugInfoKind == codegenoptions::DebugDirectivesOnly || | ||||
(DebugInfoKind == codegenoptions::DebugLineTablesOnly && | (DebugInfoKind == codegenoptions::DebugLineTablesOnly && | ||||
SplitDWARFInlining)) | SplitDWARFInlining)) | ||||
DwarfFission = DwarfFissionKind::None; | DwarfFission = DwarfFissionKind::None; | ||||
} | } | ||||
} | } | ||||
dblaikie: Rather than undoing the DwarfFission uinitialization, instead could the DwarfFission… | |||||
I could add the OPT_g_Group check to getDebugFissionKind, but that would make the effects of -g0 and "no -g at all" into two places. Having the code here makes it closer to "how DebugInfoKind == codegenoptions::NoDebugInfo affects fission" above. MaskRay: I could add the OPT_g_Group check to `getDebugFissionKind`, but that would make the effects of… | |||||
Sorry, I'm not following what you're suggesting/discussing. I wasn't meaning to suggest duplicating the OPT_g_Group check. Code something like: if (const Arg *A = Args.getLastArg(options::OPT_g_Group)) { DebugInfoKind = codegenoptions::LimitedDebugInfo; Arg* SplitDWARFArg; DwarfFission = getDebugFissionKind(D, Args, SplitDWARFArg); if (DwarfFission != DwarfFissionKind::None && !checkDebugInfoOption(SplitDWARFArg, Args, D, TC)) { DwarfFission = DwarfFissionKind::None; SplitDWARFInlining = false; } // If the last option explicitly specified a debug-info level, use it. if (checkDebugInfoOption(A, Args, D, TC) && A->getOption().matches(options::OPT_gN_Group)) { DebugInfoKind = DebugLevelToInfoKind(*A); // For -g0 or -gline-tables-only, drop -gsplit-dwarf. This gets a bit more // complicated if you've disabled inline info in the skeleton CUs // (SplitDWARFInlining) - then there's value in composing split-dwarf and // line-tables-only, so let those compose naturally in that case. if (DebugInfoKind == codegenoptions::NoDebugInfo || DebugInfoKind == codegenoptions::DebugDirectivesOnly || (DebugInfoKind == codegenoptions::DebugLineTablesOnly && SplitDWARFInlining)) DwarfFission = DwarfFissionKind::None; } } This way, hopefully, there wouldn't be a period where DwarfFission is incorrectly set and has to be reverted to "None", making it less likely the incorrect value could be used accidentally dblaikie: Sorry, I'm not following what you're suggesting/discussing. I wasn't meaning to suggest… | |||||
// If a debugger tuning argument appeared, remember it. | // If a debugger tuning argument appeared, remember it. | ||||
if (const Arg *A = | if (const Arg *A = | ||||
Args.getLastArg(options::OPT_gTune_Group, options::OPT_ggdbN_Group)) { | Args.getLastArg(options::OPT_gTune_Group, options::OPT_ggdbN_Group)) { | ||||
if (checkDebugInfoOption(A, Args, D, TC)) { | if (checkDebugInfoOption(A, Args, D, TC)) { | ||||
if (A->getOption().matches(options::OPT_glldb)) | if (A->getOption().matches(options::OPT_glldb)) | ||||
DebuggerTuning = llvm::DebuggerKind::LLDB; | DebuggerTuning = llvm::DebuggerKind::LLDB; | ||||
else if (A->getOption().matches(options::OPT_gsce)) | else if (A->getOption().matches(options::OPT_gsce)) | ||||
DebuggerTuning = llvm::DebuggerKind::SCE; | DebuggerTuning = llvm::DebuggerKind::SCE; | ||||
▲ Show 20 Lines • Show All 1,098 Lines • ▼ Show 20 Lines | #endif | ||||
codegenoptions::DebugInfoKind DebugInfoKind = codegenoptions::NoDebugInfo; | codegenoptions::DebugInfoKind DebugInfoKind = codegenoptions::NoDebugInfo; | ||||
bool EmitCodeView = false; | bool EmitCodeView = false; | ||||
// Add clang-cl arguments. | // Add clang-cl arguments. | ||||
types::ID InputType = Input.getType(); | types::ID InputType = Input.getType(); | ||||
if (D.IsCLMode()) | if (D.IsCLMode()) | ||||
AddClangCLArgs(Args, InputType, CmdArgs, &DebugInfoKind, &EmitCodeView); | AddClangCLArgs(Args, InputType, CmdArgs, &DebugInfoKind, &EmitCodeView); | ||||
DwarfFissionKind DwarfFission; | DwarfFissionKind DwarfFission = DwarfFissionKind::None; | ||||
RenderDebugOptions(TC, D, RawTriple, Args, EmitCodeView, CmdArgs, | RenderDebugOptions(TC, D, RawTriple, Args, EmitCodeView, CmdArgs, | ||||
DebugInfoKind, DwarfFission); | DebugInfoKind, DwarfFission); | ||||
// Add the split debug info name to the command lines here so we | // Add the split debug info name to the command lines here so we | ||||
// can propagate it to the backend. | // can propagate it to the backend. | ||||
bool SplitDWARF = (DwarfFission != DwarfFissionKind::None) && | bool SplitDWARF = (DwarfFission != DwarfFissionKind::None) && | ||||
(TC.getTriple().isOSBinFormatELF() || | (TC.getTriple().isOSBinFormatELF() || | ||||
TC.getTriple().isOSBinFormatWasm()) && | TC.getTriple().isOSBinFormatWasm()) && | ||||
▲ Show 20 Lines • Show All 2,516 Lines • Show Last 20 Lines |
Rather than undoing the DwarfFission uinitialization, instead could the DwarfFission initialization be rolled into the "if (gN_Group)" condition?