Index: lib/Frontend/ASTUnit.cpp =================================================================== --- lib/Frontend/ASTUnit.cpp +++ lib/Frontend/ASTUnit.cpp @@ -99,8 +99,8 @@ }; } -static llvm::sys::SmartMutex &getOnDiskMutex() { - static llvm::sys::SmartMutex M(/* recursive = */ true); +static llvm::sys::MutexBase &getOnDiskMutex() { + static llvm::sys::AtexitSafeMutex M; return M; } @@ -2893,20 +2893,20 @@ #ifndef NDEBUG ASTUnit::ConcurrencyState::ConcurrencyState() { - Mutex = new llvm::sys::MutexImpl(/*recursive=*/true); + Mutex = new llvm::sys::RecursiveMutex; } ASTUnit::ConcurrencyState::~ConcurrencyState() { - delete static_cast(Mutex); + delete static_cast(Mutex); } void ASTUnit::ConcurrencyState::start() { - bool acquired = static_cast(Mutex)->tryacquire(); + bool acquired = static_cast(Mutex)->tryacquire(); assert(acquired && "Concurrent access to ASTUnit!"); } void ASTUnit::ConcurrencyState::finish() { - static_cast(Mutex)->release(); + static_cast(Mutex)->release(); } #else // NDEBUG Index: tools/libclang/CIndex.cpp =================================================================== --- tools/libclang/CIndex.cpp +++ tools/libclang/CIndex.cpp @@ -45,6 +45,7 @@ #include "llvm/Support/Format.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Mutex.h" +#include "llvm/Support/MutexGuard.h" #include "llvm/Support/Program.h" #include "llvm/Support/SaveAndRestore.h" #include "llvm/Support/Signals.h" @@ -2556,7 +2557,7 @@ // Misc. API hooks. //===----------------------------------------------------------------------===// -static llvm::sys::Mutex EnableMultithreadingMutex; +static llvm::sys::RecursiveMutex EnableMultithreadingMutex; static bool EnabledMultithreading; static void fatal_error_handler(void *user_data, const std::string& reason, @@ -2577,7 +2578,7 @@ // Enable support for multithreading in LLVM. { - llvm::sys::ScopedLock L(EnableMultithreadingMutex); + llvm::MutexGuard L(EnableMultithreadingMutex); if (!EnabledMultithreading) { llvm::install_fatal_error_handler(fatal_error_handler, 0); llvm::llvm_start_multithreaded(); @@ -6958,7 +6959,7 @@ cxindex::Logger::~Logger() { LogOS.flush(); - llvm::sys::ScopedLock L(EnableMultithreadingMutex); + llvm::MutexGuard L(EnableMultithreadingMutex); static llvm::TimeRecord sBeginTR = llvm::TimeRecord::getCurrentTime(); Index: tools/libclang/Indexing.cpp =================================================================== --- tools/libclang/Indexing.cpp +++ tools/libclang/Indexing.cpp @@ -146,7 +146,7 @@ namespace { class SessionSkipBodyData { - llvm::sys::Mutex Mux; + llvm::sys::RecursiveMutex Mux; PPRegionSetTy ParsedRegions; public: