From 3459ce2e5ebbabb8d4dde3809da50dc89e1b0b35 Mon Sep 17 00:00:00 2001 From: Douglas Katzman Date: Thu, 8 Oct 2015 04:24:12 +0000 Subject: Stop messing with the 'g' group of options in CompilerInvocation. With this change, most 'g' options are rejected by CompilerInvocation. They remain only as Driver options. The new way to request debug info from cc1 is with "-debug-info-kind={line-tables-only|limited|standalone}" and "-dwarf-version={2|3|4}". In the absence of a command-line option to specify Dwarf version, the Toolchain decides it, rather than placing Toolchain-specific logic in CompilerInvocation. Also fix a bug in the Windows compatibility argument parsing in which the "rightmost argument wins" principle failed. Differential Revision: http://reviews.llvm.org/D13221 llvm-svn: 249655 --- clang/lib/Frontend/CompilerInvocation.cpp | 38 ++++++++----------------------- 1 file changed, 9 insertions(+), 29 deletions(-) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 8a7e879d07b..7667c109556 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -393,37 +393,17 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK, Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name; } - if (Args.hasArg(OPT_gline_tables_only)) { - Opts.setDebugInfo(CodeGenOptions::DebugLineTablesOnly); - } else if (Args.hasArg(OPT_g_Flag) || Args.hasArg(OPT_gdwarf_2) || - Args.hasArg(OPT_gdwarf_3) || Args.hasArg(OPT_gdwarf_4)) { - bool Default = false; - // Until dtrace (via CTF) and LLDB can deal with distributed debug info, - // Darwin and FreeBSD default to standalone/full debug info. - if (llvm::Triple(TargetOpts.Triple).isOSDarwin() || - llvm::Triple(TargetOpts.Triple).isOSFreeBSD()) - Default = true; - - if (Args.hasFlag(OPT_fstandalone_debug, OPT_fno_standalone_debug, Default)) - Opts.setDebugInfo(CodeGenOptions::FullDebugInfo); - else - Opts.setDebugInfo(CodeGenOptions::LimitedDebugInfo); - } + if (Arg *A = Args.getLastArg(OPT_debug_info_kind_EQ)) { + Opts.setDebugInfo( + llvm::StringSwitch(A->getValue()) + .Case("line-tables-only", CodeGenOptions::DebugLineTablesOnly) + .Case("limited", CodeGenOptions::LimitedDebugInfo) + .Case("standalone", CodeGenOptions::FullDebugInfo)); + } + Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 0, Diags); Opts.DebugColumnInfo = Args.hasArg(OPT_dwarf_column_info); - if (Args.hasArg(OPT_gcodeview)) { - Opts.EmitCodeView = true; - Opts.DwarfVersion = 0; - } else if (Opts.getDebugInfo() != CodeGenOptions::NoDebugInfo) { - // Default Dwarf version is 4 if we are generating debug information. - Opts.DwarfVersion = 4; - } + Opts.EmitCodeView = Args.hasArg(OPT_gcodeview); Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file); - if (Args.hasArg(OPT_gdwarf_2)) - Opts.DwarfVersion = 2; - else if (Args.hasArg(OPT_gdwarf_3)) - Opts.DwarfVersion = 3; - else if (Args.hasArg(OPT_gdwarf_4)) - Opts.DwarfVersion = 4; Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs); if (const Arg *A = -- cgit v1.2.3