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