Clang side changes accompanying the LLVM mutex refactor
http://reviews.llvm.org/D3961
Files:
lib/Frontend/ASTUnit.cpp
tools/libclang/CIndex.cpp
tools/libclang/Indexing.cpp
Index: lib/Frontend/ASTUnit.cpp
===================================================================
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -48,6 +48,7 @@
#include <cstdio>
#include <cstdlib>
#include <sys/stat.h>
+
using namespace clang;
using llvm::TimeRecord;
@@ -99,8 +100,14 @@
};
}
-static llvm::sys::SmartMutex<false> &getOnDiskMutex() {
- static llvm::sys::SmartMutex<false> M(/* recursive = */ true);
+static llvm::sys::MutexBase &getOnDiskMutex() {
+#if defined(LLVM_ON_WIN32)
+ // The default mutex implementation on Windows cannot be used during an atexit
+ // handler. The workaround is to use a critical section for this case.
+ static llvm::sys::CriticalSectionMutex M;
+#else
+ static llvm::sys::RecursiveMutex M;
+#endif
return M;
}
@@ -2893,20 +2900,20 @@
#ifndef NDEBUG
ASTUnit::ConcurrencyState::ConcurrencyState() {
- Mutex = new llvm::sys::MutexImpl(/*recursive=*/true);
+ Mutex = new llvm::sys::RecursiveMutex;
}
ASTUnit::ConcurrencyState::~ConcurrencyState() {
- delete static_cast<llvm::sys::MutexImpl *>(Mutex);
+ delete static_cast<llvm::sys::RecursiveMutex *>(Mutex);
}
void ASTUnit::ConcurrencyState::start() {
- bool acquired = static_cast<llvm::sys::MutexImpl *>(Mutex)->tryacquire();
+ bool acquired = static_cast<llvm::sys::RecursiveMutex *>(Mutex)->tryacquire();
assert(acquired && "Concurrent access to ASTUnit!");
}
void ASTUnit::ConcurrencyState::finish() {
- static_cast<llvm::sys::MutexImpl *>(Mutex)->release();
+ static_cast<llvm::sys::RecursiveMutex *>(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:
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits