diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -631,6 +631,13 @@ CmdArgs.push_back( Args.MakeArgString(Twine("-plugin-opt=stats-file=") + StatsFile)); + // Setup crash diagnostics dir. + if (Args.hasArg(options::OPT_fcrash_diagnostics_dir)) { + StringRef Dir = Args.getLastArgValue(options::OPT_fcrash_diagnostics_dir); + CmdArgs.push_back( + Args.MakeArgString("-plugin-opt=-crash-diagnostics-dir=" + Dir)); + } + addX86AlignBranchArgs(D, Args, CmdArgs, /*IsLTO=*/true); // Handle remark diagnostics on screen options: '-Rpass-*'. diff --git a/clang/test/Driver/crash-diagnostics-dir-2.c b/clang/test/Driver/crash-diagnostics-dir-2.c --- a/clang/test/Driver/crash-diagnostics-dir-2.c +++ b/clang/test/Driver/crash-diagnostics-dir-2.c @@ -3,3 +3,12 @@ // OPTION: "-crash-diagnostics-dir=mydumps" // RUN: %clang -### -c %s 2>&1 | FileCheck %s --check-prefix=NOOPTION // NOOPTION-NOT: "-crash-diagnostics-dir + +// RUN: %clang -### -fcrash-diagnostics-dir=mydumps -flto %s 2>&1 \ +// RUN: | FileCheck %s --check-prefix=LTO-OPTION +// LTO-OPTION: "-cc1" +// LTO-OPTION: "-plugin-opt=-crash-diagnostics-dir=mydumps" + +// RUN: %clang -### -flto %s 2>&1 | FileCheck %s --check-prefix=LTO-NOOPTION +// LTO-NOOPTION: "-cc1" +// LTO-NOOPTION-NOT: "-plugin-opt=-crash-diagnostics-dir=mydumps"