Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / unittests / libclang / CrashTests / LibclangCrashTest.cpp
blob26c63cfbd427b0157097f32ad8ff1b0f5e706c8b
1 //===- unittests/libclang/LibclangCrashTest.cpp --- libclang tests --------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #include "../TestUtils.h"
10 #include "clang-c/FatalErrorHandler.h"
11 #include "gtest/gtest.h"
12 #include <string>
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,
22 nullptr, 0, TUFlags),
23 "");
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,
35 nullptr, 0, TUFlags),
36 "ERROR");