Debian Codegraph @

clang/test/Index/crash-recovery-modules.m

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