This was using call_once because msvc didn't support function local static thread safe initialization.  But it does now in msvc 2015.<br><br>Can you fix HostInfoBase `g_flags` while you're at it?<br><div class="gmail_quote"><div dir="ltr">On Wed, Oct 19, 2016 at 8:21 AM Pavel Labath via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: labath<br class="gmail_msg">
Date: Wed Oct 19 10:12:45 2016<br class="gmail_msg">
New Revision: 284601<br class="gmail_msg">
<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=284601&view=rev" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project?rev=284601&view=rev</a><br class="gmail_msg">
Log:<br class="gmail_msg">
Simplify GetGlobalProperties functions of Thread/Process/Target<br class="gmail_msg">
<br class="gmail_msg">
Summary:<br class="gmail_msg">
"Initialization of function-local statics is guaranteed to occur only once even when called from<br class="gmail_msg">
multiple threads, and may be more efficient than the equivalent code using std::call_once."<br class="gmail_msg">
<<a href="http://en.cppreference.com/w/cpp/thread/call_once" rel="noreferrer" class="gmail_msg" target="_blank">http://en.cppreference.com/w/cpp/thread/call_once</a>><br class="gmail_msg">
<br class="gmail_msg">
I'd add that it's also more readable.<br class="gmail_msg">
<br class="gmail_msg">
Reviewers: clayborg, zturner<br class="gmail_msg">
<br class="gmail_msg">
Subscribers: lldb-commits<br class="gmail_msg">
<br class="gmail_msg">
Differential Revision: <a href="http://reviews.llvm.org/D17710" rel="noreferrer" class="gmail_msg" target="_blank">http://reviews.llvm.org/D17710</a><br class="gmail_msg">
<br class="gmail_msg">
Modified:<br class="gmail_msg">
    lldb/trunk/source/Target/Process.cpp<br class="gmail_msg">
    lldb/trunk/source/Target/Target.cpp<br class="gmail_msg">
    lldb/trunk/source/Target/Thread.cpp<br class="gmail_msg">
<br class="gmail_msg">
Modified: lldb/trunk/source/Target/Process.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=284601&r1=284600&r2=284601&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=284601&r1=284600&r2=284601&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- lldb/trunk/source/Target/Process.cpp (original)<br class="gmail_msg">
+++ lldb/trunk/source/Target/Process.cpp Wed Oct 19 10:12:45 2016<br class="gmail_msg">
@@ -812,11 +812,8 @@ Process::~Process() {<br class="gmail_msg">
 const ProcessPropertiesSP &Process::GetGlobalProperties() {<br class="gmail_msg">
   // NOTE: intentional leak so we don't crash if global destructor chain gets<br class="gmail_msg">
   // called as other threads still use the result of this function<br class="gmail_msg">
-  static ProcessPropertiesSP *g_settings_sp_ptr = nullptr;<br class="gmail_msg">
-  static std::once_flag g_once_flag;<br class="gmail_msg">
-  std::call_once(g_once_flag, []() {<br class="gmail_msg">
-    g_settings_sp_ptr = new ProcessPropertiesSP(new ProcessProperties(nullptr));<br class="gmail_msg">
-  });<br class="gmail_msg">
+  static ProcessPropertiesSP *g_settings_sp_ptr =<br class="gmail_msg">
+      new ProcessPropertiesSP(new ProcessProperties(nullptr));<br class="gmail_msg">
   return *g_settings_sp_ptr;<br class="gmail_msg">
 }<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Modified: lldb/trunk/source/Target/Target.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=284601&r1=284600&r2=284601&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=284601&r1=284600&r2=284601&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- lldb/trunk/source/Target/Target.cpp (original)<br class="gmail_msg">
+++ lldb/trunk/source/Target/Target.cpp Wed Oct 19 10:12:45 2016<br class="gmail_msg">
@@ -2643,11 +2643,8 @@ void Target::RunStopHooks() {<br class="gmail_msg">
 const TargetPropertiesSP &Target::GetGlobalProperties() {<br class="gmail_msg">
   // NOTE: intentional leak so we don't crash if global destructor chain gets<br class="gmail_msg">
   // called as other threads still use the result of this function<br class="gmail_msg">
-  static TargetPropertiesSP *g_settings_sp_ptr = nullptr;<br class="gmail_msg">
-  static std::once_flag g_once_flag;<br class="gmail_msg">
-  std::call_once(g_once_flag, []() {<br class="gmail_msg">
-    g_settings_sp_ptr = new TargetPropertiesSP(new TargetProperties(nullptr));<br class="gmail_msg">
-  });<br class="gmail_msg">
+  static TargetPropertiesSP *g_settings_sp_ptr =<br class="gmail_msg">
+      new TargetPropertiesSP(new TargetProperties(nullptr));<br class="gmail_msg">
   return *g_settings_sp_ptr;<br class="gmail_msg">
 }<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Modified: lldb/trunk/source/Target/Thread.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=284601&r1=284600&r2=284601&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=284601&r1=284600&r2=284601&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- lldb/trunk/source/Target/Thread.cpp (original)<br class="gmail_msg">
+++ lldb/trunk/source/Target/Thread.cpp Wed Oct 19 10:12:45 2016<br class="gmail_msg">
@@ -58,11 +58,8 @@ using namespace lldb_private;<br class="gmail_msg">
 const ThreadPropertiesSP &Thread::GetGlobalProperties() {<br class="gmail_msg">
   // NOTE: intentional leak so we don't crash if global destructor chain gets<br class="gmail_msg">
   // called as other threads still use the result of this function<br class="gmail_msg">
-  static ThreadPropertiesSP *g_settings_sp_ptr = nullptr;<br class="gmail_msg">
-  static std::once_flag g_once_flag;<br class="gmail_msg">
-  std::call_once(g_once_flag, []() {<br class="gmail_msg">
-    g_settings_sp_ptr = new ThreadPropertiesSP(new ThreadProperties(true));<br class="gmail_msg">
-  });<br class="gmail_msg">
+  static ThreadPropertiesSP *g_settings_sp_ptr =<br class="gmail_msg">
+      new ThreadPropertiesSP(new ThreadProperties(true));<br class="gmail_msg">
   return *g_settings_sp_ptr;<br class="gmail_msg">
 }<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
lldb-commits mailing list<br class="gmail_msg">
<a href="mailto:lldb-commits@lists.llvm.org" class="gmail_msg" target="_blank">lldb-commits@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br class="gmail_msg">
</blockquote></div>