Эх сурвалжийг харах

Replace non-recursive sys::Mutex users with std::mutex

Also remove a use of sys::MutexImpl, that's just evil. No functionality
change intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368157 91177308-0d34-0410-b5e6-96231b3b80d8
Benjamin Kramer 6 жил өмнө
parent
commit
838c29d058

+ 1 - 1
include/clang/Frontend/ASTUnit.h

@@ -390,7 +390,7 @@ private:
   /// just about any usage.
   /// just about any usage.
   /// Becomes a noop in release mode; only useful for debug mode checking.
   /// Becomes a noop in release mode; only useful for debug mode checking.
   class ConcurrencyState {
   class ConcurrencyState {
-    void *Mutex; // a llvm::sys::MutexImpl in debug;
+    void *Mutex; // a std::recursive_mutex in debug;
 
 
   public:
   public:
     ConcurrencyState();
     ConcurrencyState();

+ 5 - 5
lib/Frontend/ASTUnit.cpp

@@ -85,7 +85,6 @@
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Mutex.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/raw_ostream.h"
@@ -96,6 +95,7 @@
 #include <cstdio>
 #include <cstdio>
 #include <cstdlib>
 #include <cstdlib>
 #include <memory>
 #include <memory>
+#include <mutex>
 #include <string>
 #include <string>
 #include <tuple>
 #include <tuple>
 #include <utility>
 #include <utility>
@@ -2692,20 +2692,20 @@ InputKind ASTUnit::getInputKind() const {
 
 
 #ifndef NDEBUG
 #ifndef NDEBUG
 ASTUnit::ConcurrencyState::ConcurrencyState() {
 ASTUnit::ConcurrencyState::ConcurrencyState() {
-  Mutex = new llvm::sys::MutexImpl(/*recursive=*/true);
+  Mutex = new std::recursive_mutex;
 }
 }
 
 
 ASTUnit::ConcurrencyState::~ConcurrencyState() {
 ASTUnit::ConcurrencyState::~ConcurrencyState() {
-  delete static_cast<llvm::sys::MutexImpl *>(Mutex);
+  delete static_cast<std::recursive_mutex *>(Mutex);
 }
 }
 
 
 void ASTUnit::ConcurrencyState::start() {
 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!");
   assert(acquired && "Concurrent access to ASTUnit!");
 }
 }
 
 
 void ASTUnit::ConcurrencyState::finish() {
 void ASTUnit::ConcurrencyState::finish() {
-  static_cast<llvm::sys::MutexImpl *>(Mutex)->release();
+  static_cast<std::recursive_mutex *>(Mutex)->unlock();
 }
 }
 
 
 #else // NDEBUG
 #else // NDEBUG

+ 3 - 5
tools/libclang/Indexing.cpp

@@ -28,7 +28,6 @@
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Mutex.h"
 #include <cstdio>
 #include <cstdio>
 #include <mutex>
 #include <mutex>
 #include <utility>
 #include <utility>
@@ -122,22 +121,21 @@ namespace llvm {
 namespace {
 namespace {
 
 
 class SessionSkipBodyData {
 class SessionSkipBodyData {
-  llvm::sys::Mutex Mux;
+  std::mutex Mux;
   PPRegionSetTy ParsedRegions;
   PPRegionSetTy ParsedRegions;
 
 
 public:
 public:
-  SessionSkipBodyData() : Mux(/*recursive=*/false) {}
   ~SessionSkipBodyData() {
   ~SessionSkipBodyData() {
     //llvm::errs() << "RegionData: " << Skipped.size() << " - " << Skipped.getMemorySize() << "\n";
     //llvm::errs() << "RegionData: " << Skipped.size() << " - " << Skipped.getMemorySize() << "\n";
   }
   }
 
 
   void copyTo(PPRegionSetTy &Set) {
   void copyTo(PPRegionSetTy &Set) {
-    std::lock_guard<llvm::sys::Mutex> MG(Mux);
+    std::lock_guard<std::mutex> MG(Mux);
     Set = ParsedRegions;
     Set = ParsedRegions;
   }
   }
 
 
   void update(ArrayRef<PPRegion> Regions) {
   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());
     ParsedRegions.insert(Regions.begin(), Regions.end());
   }
   }
 };
 };