From 084148fcc35d96afba07a8f12842bc80af778ece Mon Sep 17 00:00:00 2001 From: Adrian McCarthy Date: Thu, 25 Aug 2016 18:24:35 +0000 Subject: [PATCH] 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 llvm-svn: 279765 --- clang/include/clang/Driver/Options.td | 4 ++-- clang/lib/Driver/Tools.cpp | 12 ++++++++---- clang/test/Driver/cl-options.c | 9 +++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 44e588d..f7efb58 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/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/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 2db1b60..f8c713c3 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/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/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c index 98548d7..25974ba 100644 --- a/clang/test/Driver/cl-options.c +++ b/clang/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 -- 2.7.4