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