diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2014-06-27 15:14:39 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2014-06-27 15:14:39 +0000 |
commit | 7896f834da1eb8de232b9476f7a22323012cd19a (patch) | |
tree | 07b4093401c519064aca7438c825f966138bf017 | |
parent | dc111a9e363412c7b1a3387333cb81049678c738 (diff) | |
download | clang-7896f834da1eb8de232b9476f7a22323012cd19a.tar.gz clang-7896f834da1eb8de232b9476f7a22323012cd19a.tar.bz2 clang-7896f834da1eb8de232b9476f7a22323012cd19a.tar.xz |
This fixes libclang to cope with the now compile-time multithreaded
selection re-enabled in r211900 in LLVM.
The approach (unlike r211121) doesn't rely on std::mutex or
std::call_once to avoid breaknig cygwin bots.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211901 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/libclang/CIndex.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 78144d50e5..1d6258b0cb 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -43,6 +43,7 @@ #include "llvm/Support/Compiler.h" #include "llvm/Support/CrashRecoveryContext.h" #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" @@ -2591,9 +2592,6 @@ buildPieces(unsigned NameFlags, bool IsMemberRefExpr, // Misc. API hooks. //===----------------------------------------------------------------------===// -static llvm::sys::Mutex EnableMultithreadingMutex; -static bool EnabledMultithreading; - static void fatal_error_handler(void *user_data, const std::string& reason, bool gen_crash_diag) { // Write the result out to stderr avoiding errs() because raw_ostreams can @@ -2610,15 +2608,7 @@ CXIndex clang_createIndex(int excludeDeclarationsFromPCH, if (!getenv("LIBCLANG_DISABLE_CRASH_RECOVERY")) llvm::CrashRecoveryContext::Enable(); - // Enable support for multithreading in LLVM. - { - llvm::sys::ScopedLock L(EnableMultithreadingMutex); - if (!EnabledMultithreading) { - llvm::install_fatal_error_handler(fatal_error_handler, nullptr); - llvm::llvm_start_multithreaded(); - EnabledMultithreading = true; - } - } + llvm::install_fatal_error_handler(fatal_error_handler, nullptr); CIndexer *CIdxr = new CIndexer(); if (excludeDeclarationsFromPCH) @@ -6999,10 +6989,12 @@ Logger &cxindex::Logger::operator<<(const llvm::format_object_base &Fmt) { return *this; } +static llvm::ManagedStatic<llvm::sys::Mutex> LoggingMutex; + cxindex::Logger::~Logger() { LogOS.flush(); - llvm::sys::ScopedLock L(EnableMultithreadingMutex); + llvm::sys::ScopedLock L(*LoggingMutex); static llvm::TimeRecord sBeginTR = llvm::TimeRecord::getCurrentTime(); |