From 4dca83cfe37ebf3cd78d180a351403a9c508701c Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Tue, 10 Jun 2014 23:02:10 +0000 Subject: [PATCH] Clang changes to support LLVM removal of runtime multithreading support (llvm revision r210600). Reviewers: rnk Differential Revision: http://reviews.llvm.org/D4077 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210601 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/libclang/CIndex.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 4d296d46b7..7320bbd085 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -2556,8 +2556,8 @@ buildPieces(unsigned NameFlags, bool IsMemberRefExpr, // Misc. API hooks. //===----------------------------------------------------------------------===// -static llvm::sys::Mutex EnableMultithreadingMutex; -static bool EnabledMultithreading; +static llvm::sys::Mutex LoggingMutex; +static std::once_flag InstalledErrorHandlerFlag; static void fatal_error_handler(void *user_data, const std::string& reason, bool gen_crash_diag) { @@ -2575,15 +2575,8 @@ CXIndex clang_createIndex(int excludeDeclarationsFromPCH, 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; - } - } + std::call_once(InstalledErrorHandlerFlag, + []() {llvm::install_fatal_error_handler(fatal_error_handler, nullptr);}); CIndexer *CIdxr = new CIndexer(); if (excludeDeclarationsFromPCH) @@ -6959,7 +6952,7 @@ Logger &cxindex::Logger::operator<<(const llvm::format_object_base &Fmt) { cxindex::Logger::~Logger() { LogOS.flush(); - llvm::sys::ScopedLock L(EnableMultithreadingMutex); + llvm::sys::ScopedLock L(LoggingMutex); static llvm::TimeRecord sBeginTR = llvm::TimeRecord::getCurrentTime(); -- 2.40.0