From bab5a5d70434b2131186600aa055954eadac3a15 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. llvm-svn: 278139 --- clang/lib/Driver/Tools.cpp | 9 +++++---- clang/test/Driver/cl-options.c | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index d0dee663cf18..a9d940f2a678 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/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/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c index 223d37e5f440..4d9416b1f87c 100644 --- a/clang/test/Driver/cl-options.c +++ b/clang/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"