#include "llvm/Support/Compiler.h"
#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/Support/Format.h"
+#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Mutex.h"
#include "llvm/Support/Program.h"
// Misc. API hooks.
//===----------------------------------------------------------------------===//
-static llvm::sys::Mutex EnableMultithreadingMutex;
-static bool EnabledMultithreading;
-
static void fatal_error_handler(void *user_data, const std::string& reason,
bool gen_crash_diag) {
// Write the result out to stderr avoiding errs() because raw_ostreams can
if (!getenv("LIBCLANG_DISABLE_CRASH_RECOVERY"))
llvm::CrashRecoveryContext::Enable();
- // Enable support for multithreading in LLVM.
- {
- llvm::sys::ScopedLock L(EnableMultithreadingMutex);
- if (!EnabledMultithreading) {
- llvm::install_fatal_error_handler(fatal_error_handler, nullptr);
- llvm::llvm_start_multithreaded();
- EnabledMultithreading = true;
- }
- }
+ llvm::install_fatal_error_handler(fatal_error_handler, nullptr);
CIndexer *CIdxr = new CIndexer();
if (excludeDeclarationsFromPCH)
return *this;
}
+static llvm::ManagedStatic<llvm::sys::Mutex> LoggingMutex;
+
cxindex::Logger::~Logger() {
LogOS.flush();
- llvm::sys::ScopedLock L(EnableMultithreadingMutex);
+ llvm::sys::ScopedLock L(*LoggingMutex);
static llvm::TimeRecord sBeginTR = llvm::TimeRecord::getCurrentTime();