Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -1216,8 +1216,14 @@ static void printArgList(raw_ostream &OS, const llvm::opt::ArgList &Args) { llvm::opt::ArgStringList ASL; - for (const auto *A : Args) + for (const auto *A : Args) { + // Use user's original spelling of flags. For example, use + // `/source-charset:utf-8` instead of `-finput-charset=utf-8` if the user + // wrote the former. + while (A->getAlias()) + A = A->getAlias(); A->render(Args, ASL); + } for (auto I = ASL.begin(), E = ASL.end(); I != E; ++I) { if (I != ASL.begin()) Index: clang/test/Driver/crash-report-clang-cl.c =================================================================== --- /dev/null +++ clang/test/Driver/crash-report-clang-cl.c @@ -0,0 +1,24 @@ +// RUN: rm -rf %t +// RUN: mkdir %t + +// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1 \ +// RUN: not %clang_cl -fsyntax-only /Brepro /source-charset:utf-8 \ +// RUN: -- %s 2>&1 | FileCheck %s +// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s + +// REQUIRES: crash-recovery + +#pragma clang __debug crash + +// CHECK: Preprocessed source(s) and associated run script(s) are located at: +// CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-clang-cl-{{.*}}.c +// CHECKSH: # Crash reproducer +// CHECKSH-NEXT: # Driver args: {{.*}}"-fsyntax-only" +// CHECKSH-SAME: /Brepro +// CHECKSH-SAME: /source-charset:utf-8 +// CHECKSH-NOT: -mno-incremental-linker-compatible +// CHECKSH-NOT: -finput-charset=utf-8 +// CHECKSH-NEXT: # Original command: {{.*$}} +// CHECKSH-NEXT: "-cc1" +// CHECKSH: "-main-file-name" "crash-report-clang-cl.c" +// CHECKSH: "crash-report-{{[^ ]*}}.c"