1 // RUN: export LSAN_OPTIONS=detect_leaks=0
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.rsp
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 %s
16 // RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
17 // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
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 %s
22 // RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
23 // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
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 %s
28 // RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
29 // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
31 // Test manually specifying -fcrash-diagnostics[=[compiler|all]] emits
33 // 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 | \
37 // RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
38 // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
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 |\
44 // RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
45 // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
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 | \
51 // RUN: cat %t/crash-report-*.cpp | FileCheck --check-prefix=CHECKSRC %s
52 // RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s
54 // REQUIRES: crash-recovery
57 #pragma clang __debug parser_crash
59 #pragma clang __debug crash
61 #pragma clang __debug llvm_fatal_error
64 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
65 // CHECK-NEXT: note: diagnostic msg: {{.*}}crash-report-{{.*}}.cpp
67 // __has_feature(cxx_exceptions) is default-on in the gcc-compatible driver.
69 #if __has_feature(cxx_exceptions)
75 // CHECKSRC-NEXT: {{^}}#if 0 /* disabled by -frewrite-includes */
76 // CHECKSRC-NEXT: {{^}}#if __has_feature(cxx_exceptions)
77 // CHECKSRC-NEXT: {{^}}#endif
78 // 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: {{^}}#else
83 // CHECKSRC-NEXT: {{^}}#
84 // CHECKSRC-NEXT: {{^}}int a = 0;
85 // CHECKSRC-NEXT: {{^}}#endif
87 // CHECKSH: # Crash reproducer
88 // 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"