[Lldb-commits] [lldb] r346673 - [lldb] Fix "code requires global destructor" warning in g_architecture_mutex
Kuba Mracek via lldb-commits
lldb-commits at lists.llvm.org
Mon Nov 12 08:52:58 PST 2018
Author: kuba.brecka
Date: Mon Nov 12 08:52:58 2018
New Revision: 346673
URL: http://llvm.org/viewvc/llvm-project?rev=346673&view=rev
Log:
[lldb] Fix "code requires global destructor" warning in g_architecture_mutex
Differential Revision: https://reviews.llvm.org/D44060
Modified:
lldb/trunk/source/Core/PluginManager.cpp
Modified: lldb/trunk/source/Core/PluginManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=346673&r1=346672&r2=346673&view=diff
==============================================================================
--- lldb/trunk/source/Core/PluginManager.cpp (original)
+++ lldb/trunk/source/Core/PluginManager.cpp Mon Nov 12 08:52:58 2018
@@ -286,7 +286,10 @@ struct ArchitectureInstance {
typedef std::vector<ArchitectureInstance> ArchitectureInstances;
-static std::mutex g_architecture_mutex;
+static std::mutex &GetArchitectureMutex() {
+ static std::mutex g_architecture_mutex;
+ return g_architecture_mutex;
+}
static ArchitectureInstances &GetArchitectureInstances() {
static ArchitectureInstances g_instances;
@@ -296,13 +299,13 @@ static ArchitectureInstances &GetArchite
void PluginManager::RegisterPlugin(const ConstString &name,
llvm::StringRef description,
ArchitectureCreateInstance create_callback) {
- std::lock_guard<std::mutex> guard(g_architecture_mutex);
+ std::lock_guard<std::mutex> guard(GetArchitectureMutex());
GetArchitectureInstances().push_back({name, description, create_callback});
}
void PluginManager::UnregisterPlugin(
ArchitectureCreateInstance create_callback) {
- std::lock_guard<std::mutex> guard(g_architecture_mutex);
+ std::lock_guard<std::mutex> guard(GetArchitectureMutex());
auto &instances = GetArchitectureInstances();
for (auto pos = instances.begin(), end = instances.end(); pos != end; ++pos) {
@@ -316,7 +319,7 @@ void PluginManager::UnregisterPlugin(
std::unique_ptr<Architecture>
PluginManager::CreateArchitectureInstance(const ArchSpec &arch) {
- std::lock_guard<std::mutex> guard(g_architecture_mutex);
+ std::lock_guard<std::mutex> guard(GetArchitectureMutex());
for (const auto &instances : GetArchitectureInstances()) {
if (auto plugin_up = instances.create_callback(arch))
return plugin_up;
More information about the lldb-commits
mailing list