1 //===- unittests/libclang/LibclangCrashTest.cpp --- libclang tests --------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "../TestUtils.h"
10 #include "clang-c/FatalErrorHandler.h"
11 #include "gtest/gtest.h"
14 TEST_F(LibclangParseTest
, InstallAbortingLLVMFatalErrorHandler
) {
15 clang_toggleCrashRecovery(0);
16 clang_install_aborting_llvm_fatal_error_handler();
18 std::string Main
= "main.h";
19 WriteFile(Main
, "#pragma clang __debug llvm_fatal_error");
21 EXPECT_DEATH(clang_parseTranslationUnit(Index
, Main
.c_str(), nullptr, 0,
26 TEST_F(LibclangParseTest
, UninstallAbortingLLVMFatalErrorHandler
) {
27 clang_toggleCrashRecovery(0);
28 clang_install_aborting_llvm_fatal_error_handler();
29 clang_uninstall_llvm_fatal_error_handler();
31 std::string Main
= "main.h";
32 WriteFile(Main
, "#pragma clang __debug llvm_fatal_error");
34 EXPECT_DEATH(clang_parseTranslationUnit(Index
, Main
.c_str(), nullptr, 0,