From f9ebd63d80e0276bb24f80c191a77d75887a6411 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Tue, 9 Aug 2016 17:23:56 +0000 Subject: [PATCH] [clang-cl] Make -gline-tables-only imply -gcodeview It's surprising that you have to pass /Z7 in addition to -gcodeview to get debug info. The sanitizer runtime, for example, expects that if the compiler supports the -gline-tables-only flag, then it will emit debug info. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@278139 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Tools.cpp | 9 +++++---- test/Driver/cl-options.c | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index d0dee663cf..a9d940f2a6 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -4611,8 +4611,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, options::OPT_gdwarf_4, options::OPT_gdwarf_5)) DwarfVersion = DwarfVersionNum(A->getSpelling()); - // Forward -gcodeview. - // 'EmitCodeView might have been set by CL-compatibility argument parsing. + // Forward -gcodeview. EmitCodeView might have been set by CL-compatibility + // argument parsing. if (Args.hasArg(options::OPT_gcodeview) || EmitCodeView) { // DwarfVersion remains at 0 if no explicit choice was made. CmdArgs.push_back("-gcodeview"); @@ -6402,9 +6402,10 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType, CmdArgs.push_back(Args.MakeArgString(Twine(LangOptions::SSPStrong))); } - // Emit CodeView if -Z7 or -Zd are present. + // Emit CodeView if -Z7, -Zd, or -gline-tables-only are present. if (Arg *DebugInfoArg = - Args.getLastArg(options::OPT__SLASH_Z7, options::OPT__SLASH_Zd)) { + Args.getLastArg(options::OPT__SLASH_Z7, options::OPT__SLASH_Zd, + options::OPT_gline_tables_only)) { *EmitCodeView = true; if (DebugInfoArg->getOption().matches(options::OPT__SLASH_Z7)) *DebugInfoKind = codegenoptions::LimitedDebugInfo; diff --git a/test/Driver/cl-options.c b/test/Driver/cl-options.c index 223d37e5f4..4d9416b1f8 100644 --- a/test/Driver/cl-options.c +++ b/test/Driver/cl-options.c @@ -424,6 +424,10 @@ // Z7GMLT: "-gcodeview" // Z7GMLT: "-debug-info-kind=line-tables-only" +// RUN: %clang_cl -gline-tables-only /c -### -- %s 2>&1 | FileCheck -check-prefix=ZGMLT %s +// ZGMLT: "-gcodeview" +// ZGMLT: "-debug-info-kind=line-tables-only" + // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=BreproDefault %s // BreproDefault: "-mincremental-linker-compatible" -- 2.40.0