]> granicus.if.org Git - clang/commitdiff
Replace non-recursive sys::Mutex users with std::mutex
authorBenjamin Kramer <benny.kra@googlemail.com>
Wed, 7 Aug 2019 11:59:44 +0000 (11:59 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Wed, 7 Aug 2019 11:59:44 +0000 (11:59 +0000)
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

include/clang/Frontend/ASTUnit.h
lib/Frontend/ASTUnit.cpp
tools/libclang/Indexing.cpp

index 7fb1d2d93380c8212f4fd77c2a872fe97135154c..4491bf298c1aaafe93043fed88d962a03df0d09f 100644 (file)
@@ -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();
index df0d6d4fe5e8523423d99ba035322e4410b396c5..7e3f7a2f13f57deb5da04a2bf9fb26202bab23c1 100644 (file)
@@ -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
index 36c081220524ccf65c7f1f0fcf140248ff309e87..1d30bbf6056188f013087fa587be97657cbfbe25 100644 (file)
@@ -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());
   }
 };