This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG8dfbe9b0aeb6: [clang] Make crash reproducer work with clang-cl (authored by thakis).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D110783/new/ https://reviews.llvm.org/D110783 Files: clang/lib/Driver/Driver.cpp clang/test/Driver/crash-report-clang-cl.c clang/test/Driver/crash-report-clang-cl.cpp clang/test/Driver/crash-report.c clang/test/Driver/crash-report.cpp
Index: clang/test/Driver/crash-report.cpp =================================================================== --- clang/test/Driver/crash-report.cpp +++ clang/test/Driver/crash-report.cpp @@ -6,25 +6,25 @@ // RUN: -iprefix /the/prefix -iwithprefix /tmp -iwithprefixbefore /tmp/ \ // RUN: -Xclang -internal-isystem -Xclang /tmp/ \ // RUN: -Xclang -internal-externc-isystem -Xclang /tmp/ \ -// RUN: -Xclang -main-file-name -Xclang foo.c \ +// RUN: -Xclang -main-file-name -Xclang foo.cpp \ // RUN: -DFOO=BAR -DBAR="BAZ QUX"' > %t.rsp // RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1 \ // RUN: CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1 \ // RUN: not %clang %s @%t.rsp -DPARSER 2>&1 | FileCheck %s -// RUN: cat %t/crash-report-*.c | FileCheck --check-prefix=CHECKSRC %s +// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s // RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1 \ // RUN: CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1 \ // RUN: not %clang %s @%t.rsp -DCRASH 2>&1 | FileCheck %s -// RUN: cat %t/crash-report-*.c | FileCheck --check-prefix=CHECKSRC %s +// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s // RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1 \ // RUN: CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1 \ // RUN: not %clang %s @%t.rsp -DFATAL 2>&1 | FileCheck %s -// RUN: cat %t/crash-report-*.c | FileCheck --check-prefix=CHECKSRC %s +// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s // REQUIRES: crash-recovery @@ -38,16 +38,35 @@ #endif // CHECK: Preprocessed source(s) and associated run script(s) are located at: -// CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-{{.*}}.c +// CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-{{.*}}.cpp + +// __has_feature(cxx_exceptions) is default-on in the gcc-compatible driver. FOO -// CHECKSRC: FOO +#if __has_feature(cxx_exceptions) +int a = 1; +#else +int a = 0; +#endif +// CHECKSRC: {{^}}FOO +// CHECKSRC-NEXT: {{^}}#if 0 /* disabled by -frewrite-includes */ +// CHECKSRC-NEXT: {{^}}#if __has_feature(cxx_exceptions) +// CHECKSRC-NEXT: {{^}}#endif +// CHECKSRC-NEXT: {{^}}#endif /* disabled by -frewrite-includes */ +// CHECKSRC-NEXT: {{^}}#if 1 /* evaluated by -frewrite-includes */ +// CHECKSRC-NEXT: {{^}}# +// CHECKSRC-NEXT: {{^}}int a = 1; +// CHECKSRC-NEXT: {{^}}#else +// CHECKSRC-NEXT: {{^}}# +// CHECKSRC-NEXT: {{^}}int a = 0; +// CHECKSRC-NEXT: {{^}}#endif + // CHECKSH: # Crash reproducer // CHECKSH-NEXT: # Driver args: {{.*}}"-fsyntax-only" // CHECKSH-SAME: "-D" "FOO=BAR" // CHECKSH-SAME: "-D" "BAR=BAZ QUX" // CHECKSH-NEXT: # Original command: {{.*$}} // CHECKSH-NEXT: "-cc1" -// CHECKSH: "-main-file-name" "crash-report.c" +// CHECKSH: "-main-file-name" "crash-report.cpp" // CHECKSH-NOT: "-header-include-file" // CHECKSH-NOT: "-diagnostic-log-file" // CHECKSH: "-D" "FOO=BAR" @@ -63,4 +82,4 @@ // CHECKSH-NOT: "-internal-isystem" "/tmp/" // CHECKSH-NOT: "-internal-externc-isystem" "/tmp/" // CHECKSH-NOT: "-dwarf-debug-flags" -// CHECKSH: "crash-report-{{[^ ]*}}.c" +// CHECKSH: "crash-report-{{[^ ]*}}.cpp" Index: clang/test/Driver/crash-report-clang-cl.cpp =================================================================== --- /dev/null +++ clang/test/Driver/crash-report-clang-cl.cpp @@ -0,0 +1,45 @@ +// RUN: rm -rf %t +// RUN: mkdir %t + +// RUN: not %clang_cl -fsyntax-only /Brepro /source-charset:utf-8 \ +// RUN: -fcrash-diagnostics-dir=%t -- %s 2>&1 | FileCheck %s +// RUN: cat %t/crash-report-clang-cl-*.cpp | FileCheck --check-prefix=CHECKSRC %s +// RUN: cat %t/crash-report-clang-cl-*.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: + +// __has_feature(cxx_exceptions) is default-off in the cl-compatible driver. +FOO +#if __has_feature(cxx_exceptions) +int a = 1; +#else +int a = 0; +#endif +// CHECKSRC: {{^}}FOO +// CHECKSRC-NEXT: {{^}}#if 0 /* disabled by -frewrite-includes */ +// CHECKSRC-NEXT: {{^}}#if __has_feature(cxx_exceptions) +// CHECKSRC-NEXT: {{^}}#endif +// CHECKSRC-NEXT: {{^}}#endif /* disabled by -frewrite-includes */ +// CHECKSRC-NEXT: {{^}}#if 0 /* evaluated by -frewrite-includes */ +// CHECKSRC-NEXT: {{^}}# +// CHECKSRC-NEXT: {{^}}int a = 1; +// CHECKSRC-NEXT: {{^}}#else +// CHECKSRC-NEXT: {{^}}# +// CHECKSRC-NEXT: {{^}}int a = 0; +// CHECKSRC-NEXT: {{^}}#endif + +// CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-clang-cl-{{.*}}.cpp +// 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.cpp" +// CHECKSH: "crash-report-{{[^ ]*}}.cpp" Index: clang/test/Driver/crash-report-clang-cl.c =================================================================== --- clang/test/Driver/crash-report-clang-cl.c +++ /dev/null @@ -1,24 +0,0 @@ -// 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" Index: clang/lib/Driver/Driver.cpp =================================================================== --- clang/lib/Driver/Driver.cpp +++ clang/lib/Driver/Driver.cpp @@ -277,7 +277,8 @@ if (CCCIsCPP() || (PhaseArg = DAL.getLastArg(options::OPT_E)) || (PhaseArg = DAL.getLastArg(options::OPT__SLASH_EP)) || (PhaseArg = DAL.getLastArg(options::OPT_M, options::OPT_MM)) || - (PhaseArg = DAL.getLastArg(options::OPT__SLASH_P))) { + (PhaseArg = DAL.getLastArg(options::OPT__SLASH_P)) || + CCGenDiagnostics) { FinalPhase = phases::Preprocess; // --precompile only runs up to precompilation. @@ -1343,7 +1344,6 @@ PrintVersion(C, llvm::errs()); // Suppress driver output and emit preprocessor output to temp file. - Mode = CPPMode; CCGenDiagnostics = true; // Save the original job command(s). @@ -2263,6 +2263,7 @@ // // Otherwise emit an error but still use a valid type to avoid // spurious errors (e.g., no inputs). + assert(!CCGenDiagnostics && "stdin produces no crash reproducer"); if (!Args.hasArgNoClaim(options::OPT_E) && !CCCIsCPP()) Diag(IsCLMode() ? clang::diag::err_drv_unknown_stdin_type_clang_cl : clang::diag::err_drv_unknown_stdin_type); @@ -2278,10 +2279,10 @@ Ty = TC.LookupTypeForExtension(Ext + 1); if (Ty == types::TY_INVALID) { - if (CCCIsCPP()) - Ty = types::TY_C; - else if (IsCLMode() && Args.hasArgNoClaim(options::OPT_E)) + if (IsCLMode() && (Args.hasArgNoClaim(options::OPT_E) || CCGenDiagnostics)) Ty = types::TY_CXX; + else if (CCCIsCPP() || CCGenDiagnostics) + Ty = types::TY_C; else Ty = types::TY_Object; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits