1 | // Clear out the module cache entirely, so we start from nothing. |
2 | // RUN: rm -rf %t |
3 | |
4 | // Parse the file, such that building the module will cause Clang to crash. |
5 | // RUN: not env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodules-cache-path=%t -Xclang -fdisable-module-hash -I %S/Inputs/Headers -DCRASH %s > /dev/null 2> %t.err |
6 | // RUN: FileCheck < %t.err -check-prefix=CHECK-CRASH %s |
7 | // CHECK-CRASH: crash-recovery-modules.m:17:9:{17:2-17:14}: fatal error: could not build module 'Crash' |
8 | |
9 | // Parse the file again, without crashing, to make sure that |
10 | // subsequent parses do the right thing. |
11 | // RUN: env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodules-cache-path=%t -Xclang -fdisable-module-hash -I %S/Inputs/Headers %s > /dev/null |
12 | |
13 | // REQUIRES: crash-recovery |
14 | // REQUIRES: shell |
15 | // UNSUPPORTED: libstdcxx-safe-mode |
16 | |
17 | @import Crash; |
18 | |
19 | #ifdef LIBCLANG_CRASH |
20 | #pragma clang __debug crash |
21 | #endif |
22 | |
23 | void test() { |
24 | const char* error = getCrashString(); |
25 | } |
26 | |
27 | |
28 | // RUN: rm -rf %t |
29 | // Check that libclang crash-recovery works; both with a module building crash... |
30 | // RUN: not env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodules-cache-path=%t -Xclang -fdisable-module-hash -I %S/Inputs/Headers -DCRASH -DLIBCLANG_CRASH %s > /dev/null 2> %t.err |
31 | // RUN: FileCheck < %t.err -check-prefix=CHECK-LIBCLANG-CRASH %s |
32 | // ...and with module building successful. |
33 | // RUN: not env CINDEXTEST_FAILONERROR=1 c-index-test -test-load-source all -fmodules -fmodules-cache-path=%t -Xclang -fdisable-module-hash -I %S/Inputs/Headers -DLIBCLANG_CRASH %s > /dev/null 2> %t.err |
34 | // RUN: FileCheck < %t.err -check-prefix=CHECK-LIBCLANG-CRASH %s |
35 | // CHECK-LIBCLANG-CRASH: libclang: crash detected during parsing |
36 | // CHECK-LIBCLANG-CRASH: Unable to load translation unit! |
37 | |