aeubanks updated this revision to Diff 469954. aeubanks added a comment. default to off
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D136474/new/ https://reviews.llvm.org/D136474 Files: clang/include/clang/Basic/CodeGenOptions.def clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/test/CodeGen/debug-info-codeview-buildinfo.c clang/test/Driver/gcodeview-command-line.c
Index: clang/test/Driver/gcodeview-command-line.c =================================================================== --- /dev/null +++ clang/test/Driver/gcodeview-command-line.c @@ -0,0 +1,19 @@ +// Note: %s must be preceded by --, otherwise it may be interpreted as a +// command-line option, e.g. on Mac where %s is commonly under /Users. + +// CMD: "-gcodeview-command-line" +// NO_CMD-NOT: "-gcodeview-command-line" + +// default +// RUN: %clang_cl /Z7 -### -- %s 2>&1 | FileCheck -check-prefix=NO_CMD %s +// enabled +// RUN: %clang_cl /Z7 -gno-codeview-command-line -gcodeview-command-line -### -- %s 2>&1 | FileCheck -check-prefix=CMD %s +// disabled +// RUN: %clang_cl /Z7 -gcodeview-command-line -gno-codeview-command-line -### -- %s 2>&1 | FileCheck -check-prefix=NO_CMD %s + +// enabled, no /Z7 +// RUN: %clang_cl -gcodeview-command-line -### -- %s 2>&1 | FileCheck -check-prefix=NO_CMD %s + +// GCC-style driver +// RUN: %clang -g -gcodeview -gno-codeview-command-line -gcodeview-command-line -### -- %s 2>&1 | FileCheck -check-prefix=CMD %s +// RUN: %clang -g -gcodeview -gcodeview-command-line -gno-codeview-command-line -### -- %s 2>&1 | FileCheck -check-prefix=NO_CMD %s Index: clang/test/CodeGen/debug-info-codeview-buildinfo.c =================================================================== --- clang/test/CodeGen/debug-info-codeview-buildinfo.c +++ clang/test/CodeGen/debug-info-codeview-buildinfo.c @@ -1,8 +1,12 @@ // REQUIRES: x86-registered-target -// RUN: %clang_cl --target=i686-windows-msvc /c /Z7 /Fo%t.obj -- %s +// RUN: %clang_cl -gcodeview-command-line --target=i686-windows-msvc /c /Z7 /Fo%t.obj -- %s // RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s // RUN: %clang_cl --target=i686-windows-msvc /c /Z7 /Fo%t.obj -fdebug-compilation-dir=. -- %s // RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix RELATIVE +// RUN: %clang_cl --target=i686-windows-msvc /c /Z7 /Fo%t.obj -- %s +// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix DISABLE +// RUN: %clang_cl -gno-codeview-command-line --target=i686-windows-msvc /c /Z7 /Fo%t.obj -- %s +// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix DISABLE int main(void) { return 42; } @@ -14,13 +18,21 @@ // CHECK: 0x[[TOOL:.+]] | LF_STRING_ID [size = {{.+}}] ID: <no type>, String: [[TOOLVAL:.+[\\/]clang.*]] // CHECK: 0x[[CMDLINE:.+]] | LF_STRING_ID [size = {{.+}}] ID: <no type>, String: "-cc1 // CHECK: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}] -// CHECK: 0x[[PWD]]: `[[PWDVAL]]` -// CHECK: 0x[[TOOL]]: `[[TOOLVAL]]` -// CHECK: 0x[[FILEPATH]]: `[[FILEPATHVAL]]` -// CHECK: 0x[[ZIPDB]]: `` -// CHECK: 0x[[CMDLINE]]: `"-cc1 +// CHECK-NEXT: 0x[[PWD]]: `[[PWDVAL]]` +// CHECK-NEXT: 0x[[TOOL]]: `[[TOOLVAL]]` +// CHECK-NEXT: 0x[[FILEPATH]]: `[[FILEPATHVAL]]` +// CHECK-NEXT: 0x[[ZIPDB]]: `` +// CHECK-NEXT: 0x[[CMDLINE]]: `"-cc1 // RELATIVE: Types (.debug$T) // RELATIVE: ============================================================ // RELATIVE: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}] // RELATIVE: 0x{{.+}}: `.` + +// DISABLE-NOT: cc1 +// DISABLE: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}] +// DISABLE-NEXT: 0x{{.+}}: `{{.*}}` +// DISABLE-NEXT: <no type>: `` +// DISABLE-NEXT: 0x{{.+}}: `{{.*}}` +// DISABLE-NEXT: 0x{{.+}}: `` +// DISABLE-NEXT: <no type>: `` Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -4542,8 +4542,10 @@ } // Store the command-line for using in the CodeView backend. - Res.getCodeGenOpts().Argv0 = Argv0; - append_range(Res.getCodeGenOpts().CommandLineArgs, CommandLineArgs); + if (Res.getCodeGenOpts().CodeViewCommandLine) { + Res.getCodeGenOpts().Argv0 = Argv0; + append_range(Res.getCodeGenOpts().CommandLineArgs, CommandLineArgs); + } FixupInvocation(Res, Diags, Args, DashX); Index: clang/lib/Driver/ToolChains/Clang.cpp =================================================================== --- clang/lib/Driver/ToolChains/Clang.cpp +++ clang/lib/Driver/ToolChains/Clang.cpp @@ -4346,10 +4346,12 @@ CmdArgs.push_back("-gcodeview"); // Emit codeview type hashes if requested. - if (Args.hasFlag(options::OPT_gcodeview_ghash, - options::OPT_gno_codeview_ghash, false)) { - CmdArgs.push_back("-gcodeview-ghash"); - } + Args.addOptInFlag(CmdArgs, options::OPT_gcodeview_ghash, + options::OPT_gno_codeview_ghash); + + // Emit codeview command line if requested. + Args.addOptInFlag(CmdArgs, options::OPT_gcodeview_command_line, + options::OPT_gno_codeview_command_line); } // Omit inline line tables if requested. Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -3185,6 +3185,10 @@ CodeGenOpts<"CodeViewGHash">, DefaultFalse, PosFlag<SetTrue, [CC1Option], "Emit type record hashes in a .debug$H section">, NegFlag<SetFalse>, BothFlags<[CoreOption]>>; +defm codeview_command_line : BoolOption<"g", "codeview-command-line", + CodeGenOpts<"CodeViewCommandLine">, DefaultFalse, + PosFlag<SetTrue, [CC1Option], "Emit compiler path and command line into CodeView debug information">, + NegFlag<SetFalse>, BothFlags<[CoreOption]>>; defm inline_line_tables : BoolGOption<"inline-line-tables", CodeGenOpts<"NoInlineLineTables">, DefaultFalse, NegFlag<SetTrue, [CC1Option], "Don't emit inline line tables.">, Index: clang/include/clang/Basic/CodeGenOptions.def =================================================================== --- clang/include/clang/Basic/CodeGenOptions.def +++ clang/include/clang/Basic/CodeGenOptions.def @@ -401,6 +401,9 @@ /// Whether to emit the .debug$H section containing hashes of CodeView types. CODEGENOPT(CodeViewGHash, 1, 0) +/// Whether to emit the compiler path and command line into the CodeView debug information. +CODEGENOPT(CodeViewCommandLine, 1, 0) + /// The kind of inlining to perform. ENUM_CODEGENOPT(Inlining, InliningMethod, 2, NormalInlining)
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits