r368173 - Remove LLVM mutexes from clang in favor of std::mutex

Benjamin Kramer via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 7 07:44:40 PDT 2019


Author: d0k
Date: Wed Aug  7 07:44:40 2019
New Revision: 368173

URL: http://llvm.org/viewvc/llvm-project?rev=368173&view=rev
Log:
Remove LLVM mutexes from clang in favor of std::mutex

None of those need to be recursive mutexes. No functionality change
intended.

Modified:
    cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
    cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
    cfe/trunk/tools/libclang/CIndex.cpp
    cfe/trunk/tools/libclang/CIndexer.h
    cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Modified: cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp?rev=368173&r1=368172&r2=368173&view=diff
==============================================================================
--- cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp (original)
+++ cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp Wed Aug  7 07:44:40 2019
@@ -14,7 +14,6 @@
 #include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Errno.h"
 #include "llvm/Support/Error.h"
-#include "llvm/Support/Mutex.h"
 #include "llvm/Support/Path.h"
 #include <atomic>
 #include <condition_variable>

Modified: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp?rev=368173&r1=368172&r2=368173&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp (original)
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp Wed Aug  7 07:44:40 2019
@@ -27,7 +27,6 @@
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/Mutex.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include <limits>
@@ -96,7 +95,7 @@ public:
   void removeFile(StringRef File);
 
 private:
-  llvm::sys::SmartMutex<false> Mutex;
+  std::mutex Mutex;
   llvm::StringSet<> Files;
 };
 
@@ -106,20 +105,20 @@ TemporaryFiles &TemporaryFiles::getInsta
 }
 
 TemporaryFiles::~TemporaryFiles() {
-  std::lock_guard<llvm::sys::Mutex> Guard(Mutex);
+  std::lock_guard<std::mutex> Guard(Mutex);
   for (const auto &File : Files)
     llvm::sys::fs::remove(File.getKey());
 }
 
 void TemporaryFiles::addFile(StringRef File) {
-  std::lock_guard<llvm::sys::Mutex> Guard(Mutex);
+  std::lock_guard<std::mutex> Guard(Mutex);
   auto IsInserted = Files.insert(File).second;
   (void)IsInserted;
   assert(IsInserted && "File has already been added");
 }
 
 void TemporaryFiles::removeFile(StringRef File) {
-  std::lock_guard<llvm::sys::Mutex> Guard(Mutex);
+  std::lock_guard<std::mutex> Guard(Mutex);
   auto WasPresent = Files.erase(File);
   (void)WasPresent;
   assert(WasPresent && "File was not tracked");

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=368173&r1=368172&r2=368173&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed Aug  7 07:44:40 2019
@@ -45,7 +45,6 @@
 #include "llvm/Support/Format.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Mutex.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/SaveAndRestore.h"
 #include "llvm/Support/Signals.h"
@@ -53,6 +52,7 @@
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
+#include <mutex>
 
 #if LLVM_ENABLE_THREADS != 0 && defined(__APPLE__)
 #define USE_DARWIN_THREADS
@@ -8943,10 +8943,10 @@ Logger &cxindex::Logger::operator<<(cons
   return *this;
 }
 
-static llvm::ManagedStatic<llvm::sys::Mutex> LoggingMutex;
+static llvm::ManagedStatic<std::mutex> LoggingMutex;
 
 cxindex::Logger::~Logger() {
-  llvm::sys::ScopedLock L(*LoggingMutex);
+  std::lock_guard<std::mutex> L(*LoggingMutex);
 
   static llvm::TimeRecord sBeginTR = llvm::TimeRecord::getCurrentTime();
 

Modified: cfe/trunk/tools/libclang/CIndexer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexer.h?rev=368173&r1=368172&r2=368173&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexer.h (original)
+++ cfe/trunk/tools/libclang/CIndexer.h Wed Aug  7 07:44:40 2019
@@ -17,7 +17,6 @@
 #include "clang-c/Index.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/Support/Mutex.h"
 #include <utility>
 
 namespace llvm {

Modified: cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp?rev=368173&r1=368172&r2=368173&view=diff
==============================================================================
--- cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp (original)
+++ cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp Wed Aug  7 07:44:40 2019
@@ -8,7 +8,6 @@
 
 #include "clang/DirectoryWatcher/DirectoryWatcher.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/Mutex.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include "gtest/gtest.h"




More information about the cfe-commits mailing list