From: Adrian McCarthy Date: Thu, 25 Aug 2016 18:24:35 +0000 (+0000) Subject: Omit column info for CodeView by default X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=939bf1859ca38b30920ed8a304cc6def13bbcee9;p=clang Omit column info for CodeView by default Clang tracks only start columns, not start-end ranges. CodeView allows for that, but the VS debugger doesn't handle anything less than a complete range well--it either highlights the wrong part of a statement or truncates source lines in the assembly view. It's better to have no column information at all. So by default, we'll omit the column information for CodeView targeting Windows. Since the column info is still useful for sanitizers, I've promoted -gcolumn-info (and -gno-column-info) to a CoreOption and added a couple tests to make sure that works for clang-cl. Differential Revision: https://reviews.llvm.org/D23720 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@279765 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 44e588d569..f7efb5864d 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -1305,8 +1305,8 @@ def gno_record_gcc_switches : Flag<["-"], "gno-record-gcc-switches">, Group; def gstrict_dwarf : Flag<["-"], "gstrict-dwarf">, Group; def gno_strict_dwarf : Flag<["-"], "gno-strict-dwarf">, Group; -def gcolumn_info : Flag<["-"], "gcolumn-info">, Group; -def gno_column_info : Flag<["-"], "gno-column-info">, Group; +def gcolumn_info : Flag<["-"], "gcolumn-info">, Group, Flags<[CoreOption]>; +def gno_column_info : Flag<["-"], "gno-column-info">, Group, Flags<[CoreOption]>; def gsplit_dwarf : Flag<["-"], "gsplit-dwarf">, Group; def ggnu_pubnames : Flag<["-"], "ggnu-pubnames">, Group; def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, Group; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 2db1b60d66..f8c713c344 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -2574,7 +2574,7 @@ static void getTargetFeatures(const ToolChain &TC, const llvm::Triple &Triple, case llvm::Triple::wasm32: case llvm::Triple::wasm64: getWebAssemblyTargetFeatures(Args, Features); - break; + break; case llvm::Triple::sparc: case llvm::Triple::sparcel: case llvm::Triple::sparcv9: @@ -4656,9 +4656,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // We ignore flags -gstrict-dwarf and -grecord-gcc-switches for now. Args.ClaimAllArgs(options::OPT_g_flags_Group); - // PS4 defaults to no column info + // Column info is included by default for everything except PS4 and CodeView. + // Clang doesn't track end columns, just starting columns, which, in theory, + // is fine for CodeView (and PDB). In practice, however, the Microsoft + // debuggers don't handle missing end columns well, so it's better not to + // include any column info. if (Args.hasFlag(options::OPT_gcolumn_info, options::OPT_gno_column_info, - /*Default=*/ !IsPS4CPU)) + /*Default=*/ !IsPS4CPU && !(IsWindowsMSVC && EmitCodeView))) CmdArgs.push_back("-dwarf-column-info"); // FIXME: Move backend command line options to the module. @@ -6712,7 +6716,7 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA, case llvm::Triple::mips64el: AddMIPSTargetArgs(Args, CmdArgs); break; - + case llvm::Triple::x86: case llvm::Triple::x86_64: AddX86TargetArgs(Args, CmdArgs); diff --git a/test/Driver/cl-options.c b/test/Driver/cl-options.c index 98548d7f3d..25974ba0af 100644 --- a/test/Driver/cl-options.c +++ b/test/Driver/cl-options.c @@ -50,6 +50,15 @@ // fpstrict-NOT: -menable-unsafe-fp-math // fpstrict-NOT: -ffast-math +// RUN: %clang_cl /Z7 -gcolumn-info -### -- %s 2>&1 | FileCheck -check-prefix=gcolumn %s +// gcolumn: -dwarf-column-info + +// RUN: %clang_cl /Z7 -gno-column-info -### -- %s 2>&1 | FileCheck -check-prefix=gnocolumn %s +// gnocolumn-NOT: -dwarf-column-info + +// RUN: %clang_cl /Z7 -### -- %s 2>&1 | FileCheck -check-prefix=gdefcolumn %s +// gdefcolumn-NOT: -dwarf-column-info + // RUN: %clang_cl /GA -### -- %s 2>&1 | FileCheck -check-prefix=GA %s // GA: -ftls-model=local-exec