diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Support/PrettyStackTrace.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Support/PrettyStackTrace.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/contrib/llvm-project/llvm/lib/Support/PrettyStackTrace.cpp b/contrib/llvm-project/llvm/lib/Support/PrettyStackTrace.cpp index 9072f9d2d2ee..5d3d95b5e7cb 100644 --- a/contrib/llvm-project/llvm/lib/Support/PrettyStackTrace.cpp +++ b/contrib/llvm-project/llvm/lib/Support/PrettyStackTrace.cpp @@ -25,6 +25,7 @@ #include <cassert> #include <cstdarg> #include <cstdio> +#include <cstring> #include <tuple> #ifdef HAVE_CRASHREPORTERCLIENT_H @@ -253,8 +254,16 @@ void PrettyStackTraceFormat::print(raw_ostream &OS) const { OS << Str << "\n"; } void PrettyStackTraceProgram::print(raw_ostream &OS) const { OS << "Program arguments: "; // Print the argument list. - for (unsigned i = 0, e = ArgC; i != e; ++i) - OS << ArgV[i] << ' '; + for (int I = 0; I < ArgC; ++I) { + const bool HaveSpace = ::strchr(ArgV[I], ' '); + if (I) + OS << ' '; + if (HaveSpace) + OS << '"'; + OS.write_escaped(ArgV[I]); + if (HaveSpace) + OS << '"'; + } OS << '\n'; } |