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

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

llvm-svn: 368173
This commit is contained in:
Benjamin Kramer 2019-08-07 14:44:40 +00:00
parent a06155ddc4
commit 762bc3351f
5 changed files with 7 additions and 11 deletions

View File

@ -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>

View File

@ -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::getInstance() {
}
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");

View File

@ -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<<(const llvm::format_object_base &Fmt) {
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();

View File

@ -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 {

View File

@ -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"