From 9eee7bb7e5384553f096616105e865deb7ce7d19 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Mon, 26 Feb 2018 19:25:39 +0000 Subject: [PATCH] Emit proper CodeView when -gcodeview is passed without the cl driver. Windows debuggers don't work properly when column info is emitted with lines. We handled this by checking if the driver mode was cl, but it's possible to cause the gcc driver to emit codeview as well, and in that path we were emitting column info with codeview. Differential Revision: https://reviews.llvm.org/D43700 llvm-svn: 326113 --- clang/lib/Driver/ToolChains/Clang.cpp | 4 +++- clang/test/Driver/codeview-column-info.c | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 clang/test/Driver/codeview-column-info.c diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index a2248ddaa908..6ad38bc0e403 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2968,7 +2968,7 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D, // Forward -gcodeview. EmitCodeView might have been set by CL-compatibility // argument parsing. - if (Args.hasArg(options::OPT_gcodeview) || EmitCodeView) { + if (EmitCodeView) { // DWARFVersion remains at 0 if no explicit choice was made. CmdArgs.push_back("-gcodeview"); } else if (DWARFVersion == 0 && @@ -3567,6 +3567,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, types::ID InputType = Input.getType(); if (D.IsCLMode()) AddClangCLArgs(Args, InputType, CmdArgs, &DebugInfoKind, &EmitCodeView); + else + EmitCodeView = Args.hasArg(options::OPT_gcodeview); const Arg *SplitDWARFArg = nullptr; RenderDebugOptions(getToolChain(), D, RawTriple, Args, EmitCodeView, diff --git a/clang/test/Driver/codeview-column-info.c b/clang/test/Driver/codeview-column-info.c new file mode 100644 index 000000000000..9f2f016a5f86 --- /dev/null +++ b/clang/test/Driver/codeview-column-info.c @@ -0,0 +1,13 @@ +// Check that -dwarf-column-info does not get added to the cc1 line: +// 1) When -gcodeview is present via the clang or clang++ driver +// 2) When /Z7 is present via the cl driver. + +// RUN: %clang -### -c -g -gcodeview %s 2> %t1 +// RUN: FileCheck < %t1 %s +// RUN: %clangxx -### -c -g -gcodeview %s 2> %t2 +// RUN: FileCheck < %t2 %s +// RUN: %clang_cl -### /c /Z7 %s 2> %t2 +// RUN: FileCheck < %t2 %s + +// CHECK: "-cc1" +// CHECK-NOT: "-dwarf-column-info"