::abort();
}
+namespace {
+struct RegisterFatalErrorHandler {
+ RegisterFatalErrorHandler() {
+ llvm::install_fatal_error_handler(fatal_error_handler, nullptr);
+ }
+};
+}
+
+static llvm::ManagedStatic<RegisterFatalErrorHandler> RegisterFatalErrorHandlerOnce;
+
extern "C" {
CXIndex clang_createIndex(int excludeDeclarationsFromPCH,
int displayDiagnostics) {
if (!getenv("LIBCLANG_DISABLE_CRASH_RECOVERY"))
llvm::CrashRecoveryContext::Enable();
- llvm::install_fatal_error_handler(fatal_error_handler, nullptr);
+ // Look through the managed static to trigger construction of the managed
+ // static which registers our fatal error handler. This ensures it is only
+ // registered once.
+ (void)*RegisterFatalErrorHandlerOnce;
CIndexer *CIdxr = new CIndexer();
if (excludeDeclarationsFromPCH)