38 lines · plain
1// RUN: export LSAN_OPTIONS=detect_leaks=02 3// Clear out the module cache entirely, so we start from nothing.4// RUN: rm -rf %t5 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.err8// RUN: FileCheck < %t.err -check-prefix=CHECK-CRASH %s9// 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 that12// 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/null14 15// REQUIRES: crash-recovery16// UNSUPPORTED: libstdcxx-safe-mode, hwasan17 18@import Crash;19 20#ifdef LIBCLANG_CRASH21#pragma clang __debug crash22#endif23 24void test(void) {25 const char* error = getCrashString();26}27 28 29// RUN: rm -rf %t30// 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.err32// RUN: FileCheck < %t.err -check-prefix=CHECK-LIBCLANG-CRASH %s33// ...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.err35// RUN: FileCheck < %t.err -check-prefix=CHECK-LIBCLANG-CRASH %s36// CHECK-LIBCLANG-CRASH-DAG: libclang: crash detected during parsing37// CHECK-LIBCLANG-CRASH-DAG: Unable to load translation unit!38