r368157 - Replace non-recursive sys::Mutex users with std::mutex
Benjamin Kramer via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 7 04:59:44 PDT 2019
Author: d0k
Date: Wed Aug 7 04:59:44 2019
New Revision: 368157
URL: http://llvm.org/viewvc/llvm-project?rev=368157&view=rev
Log:
Replace non-recursive sys::Mutex users with std::mutex
Also remove a use of sys::MutexImpl, that's just evil. No functionality
change intended.
Modified:
cfe/trunk/include/clang/Frontend/ASTUnit.h
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/tools/libclang/Indexing.cpp
Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=368157&r1=368156&r2=368157&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Wed Aug 7 04:59:44 2019
@@ -390,7 +390,7 @@ private:
/// just about any usage.
/// Becomes a noop in release mode; only useful for debug mode checking.
class ConcurrencyState {
- void *Mutex; // a llvm::sys::MutexImpl in debug;
+ void *Mutex; // a std::recursive_mutex in debug;
public:
ConcurrencyState();
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=368157&r1=368156&r2=368157&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Wed Aug 7 04:59:44 2019
@@ -85,7 +85,6 @@
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Mutex.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
@@ -96,6 +95,7 @@
#include <cstdio>
#include <cstdlib>
#include <memory>
+#include <mutex>
#include <string>
#include <tuple>
#include <utility>
@@ -2692,20 +2692,20 @@ InputKind ASTUnit::getInputKind() const
#ifndef NDEBUG
ASTUnit::ConcurrencyState::ConcurrencyState() {
- Mutex = new llvm::sys::MutexImpl(/*recursive=*/true);
+ Mutex = new std::recursive_mutex;
}
ASTUnit::ConcurrencyState::~ConcurrencyState() {
- delete static_cast<llvm::sys::MutexImpl *>(Mutex);
+ delete static_cast<std::recursive_mutex *>(Mutex);
}
void ASTUnit::ConcurrencyState::start() {
- bool acquired = static_cast<llvm::sys::MutexImpl *>(Mutex)->tryacquire();
+ bool acquired = static_cast<std::recursive_mutex *>(Mutex)->try_lock();
assert(acquired && "Concurrent access to ASTUnit!");
}
void ASTUnit::ConcurrencyState::finish() {
- static_cast<llvm::sys::MutexImpl *>(Mutex)->release();
+ static_cast<std::recursive_mutex *>(Mutex)->unlock();
}
#else // NDEBUG
Modified: cfe/trunk/tools/libclang/Indexing.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=368157&r1=368156&r2=368157&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/Indexing.cpp (original)
+++ cfe/trunk/tools/libclang/Indexing.cpp Wed Aug 7 04:59:44 2019
@@ -28,7 +28,6 @@
#include "clang/Lex/PreprocessorOptions.h"
#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Mutex.h"
#include <cstdio>
#include <mutex>
#include <utility>
@@ -122,22 +121,21 @@ namespace llvm {
namespace {
class SessionSkipBodyData {
- llvm::sys::Mutex Mux;
+ std::mutex Mux;
PPRegionSetTy ParsedRegions;
public:
- SessionSkipBodyData() : Mux(/*recursive=*/false) {}
~SessionSkipBodyData() {
//llvm::errs() << "RegionData: " << Skipped.size() << " - " << Skipped.getMemorySize() << "\n";
}
void copyTo(PPRegionSetTy &Set) {
- std::lock_guard<llvm::sys::Mutex> MG(Mux);
+ std::lock_guard<std::mutex> MG(Mux);
Set = ParsedRegions;
}
void update(ArrayRef<PPRegion> Regions) {
- std::lock_guard<llvm::sys::Mutex> MG(Mux);
+ std::lock_guard<std::mutex> MG(Mux);
ParsedRegions.insert(Regions.begin(), Regions.end());
}
};
More information about the cfe-commits
mailing list