110 lines · cpp
1// RUN: export LSAN_OPTIONS=detect_leaks=02// RUN: rm -rf %t3// RUN: mkdir %t4 5// RUN: echo '-fsyntax-only \6// RUN: -F/tmp/ -I /tmp/ -idirafter /tmp/ -iquote /tmp/ -isystem /tmp/ \7// RUN: -iprefix /the/prefix -iwithprefix /tmp -iwithprefixbefore /tmp/ \8// RUN: -Xclang -internal-isystem -Xclang /tmp/ \9// RUN: -Xclang -internal-externc-isystem -Xclang /tmp/ \10// RUN: -Xclang -main-file-name -Xclang foo.cpp \11// RUN: -DFOO=BAR -DBAR="BAZ QUX"' --target=x86_64-linux-gnu > %t.rsp12 13// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1 \14// RUN: CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1 \15// RUN: not %clang %s @%t.rsp -DPARSER 2>&1 | FileCheck %s16// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s17// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s18 19// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1 \20// RUN: CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1 \21// RUN: not %clang %s @%t.rsp -DCRASH 2>&1 | FileCheck %s22// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s23// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s24 25// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1 \26// RUN: CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1 \27// RUN: not %clang %s @%t.rsp -DFATAL 2>&1 | FileCheck %s28// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s29// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s30 31// Test manually specifying -fcrash-diagnostics[=[compiler|all]] emits32// diagnostics33// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1 \34// RUN: CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1 \35// RUN: not %clang %s @%t.rsp -DFATAL -fcrash-diagnostics 2>&1 | \36// RUN: FileCheck %s37// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s38// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s39 40// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1 \41// RUN: CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1 \42// RUN: not %clang %s @%t.rsp -DFATAL -fcrash-diagnostics=compiler 2>&1 |\43// RUN: FileCheck %s44// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s45// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s46 47// RUN: env TMPDIR=%t TEMP=%t TMP=%t RC_DEBUG_OPTIONS=1 \48// RUN: CC_PRINT_HEADERS=1 CC_LOG_DIAGNOSTICS=1 \49// RUN: not %clang %s @%t.rsp -DFATAL -fcrash-diagnostics=all 2>&1 | \50// RUN: FileCheck %s51// RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s52// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s53 54// REQUIRES: crash-recovery55 56#ifdef PARSER57#pragma clang __debug parser_crash58#elif CRASH59#pragma clang __debug crash60#elif FATAL61#pragma clang __debug llvm_fatal_error62#endif63 64// CHECK: Preprocessed source(s) and associated run script(s) are located at:65// CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-{{.*}}.cpp66 67// __has_feature(cxx_exceptions) is default-on in the gcc-compatible driver.68FOO69#if __has_feature(cxx_exceptions)70int a = 1;71#else72int a = 0;73#endif74// CHECKSRC: {{^}}FOO75// CHECKSRC-NEXT: {{^}}#if 0 /* disabled by -frewrite-includes */76// CHECKSRC-NEXT: {{^}}#if __has_feature(cxx_exceptions)77// CHECKSRC-NEXT: {{^}}#endif78// CHECKSRC-NEXT: {{^}}#endif /* disabled by -frewrite-includes */79// CHECKSRC-NEXT: {{^}}#if 1 /* evaluated by -frewrite-includes */80// CHECKSRC-NEXT: {{^}}#81// CHECKSRC-NEXT: {{^}}int a = 1;82// CHECKSRC-NEXT: {{^}}#else83// CHECKSRC-NEXT: {{^}}#84// CHECKSRC-NEXT: {{^}}int a = 0;85// CHECKSRC-NEXT: {{^}}#endif86 87// CHECKSH: # Crash reproducer88// CHECKSH-NEXT: # Driver args: {{.*}}"-fsyntax-only"89// CHECKSH-SAME: "-D" "FOO=BAR"90// CHECKSH-SAME: "-D" "BAR=BAZ QUX"91// CHECKSH-NEXT: # Original command: {{.*$}}92// CHECKSH-NEXT: "-cc1"93// CHECKSH: "-main-file-name" "crash-report.cpp"94// CHECKSH-NOT: "-header-include-file"95// CHECKSH-NOT: "-diagnostic-log-file"96// CHECKSH: "-D" "FOO=BAR"97// CHECKSH: "-D" "BAR=BAZ QUX"98// CHECKSH-NOT: "-F/tmp/"99// CHECKSH-NOT: "-I" "/tmp/"100// CHECKSH-NOT: "-idirafter" "/tmp/"101// CHECKSH-NOT: "-iquote" "/tmp/"102// CHECKSH-NOT: "-isystem" "/tmp/"103// CHECKSH-NOT: "-iprefix" "/the/prefix"104// CHECKSH-NOT: "-iwithprefix" "/tmp/"105// CHECKSH-NOT: "-iwithprefixbefore" "/tmp/"106// CHECKSH-NOT: "-internal-isystem" "/tmp/"107// CHECKSH-NOT: "-internal-externc-isystem" "/tmp/"108// CHECKSH-NOT: "-dwarf-debug-flags"109// CHECKSH: "crash-report-{{[^ ]*}}.cpp"110