[Lldb-commits] [lldb] r235142 - Use a singleton accessor for the static list of alternate mangling prefixes so we don't have a global constructor. Apple build systems like for shared libraries to have no global constructors.

Greg Clayton gclayton at apple.com
Thu Apr 16 16:10:22 PDT 2015


Author: gclayton
Date: Thu Apr 16 18:10:22 2015
New Revision: 235142

URL: http://llvm.org/viewvc/llvm-project?rev=235142&view=rev
Log:
Use a singleton accessor for the static list of alternate mangling prefixes so we don't have a global constructor. Apple build systems like for shared libraries to have no global constructors.

Modified:
    lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h

Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp?rev=235142&r1=235141&r2=235142&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp Thu Apr 16 18:10:22 2015
@@ -281,6 +281,14 @@ ItaniumABILanguageRuntime::IsVTableName
         return false;
 }
 
+static std::map<ConstString, std::vector<ConstString> >&
+GetAlternateManglingPrefixes()
+{
+    static std::map<ConstString, std::vector<ConstString> > g_alternate_mangling_prefixes;
+    return g_alternate_mangling_prefixes;
+}
+
+
 size_t
 ItaniumABILanguageRuntime::GetAlternateManglings(const ConstString &mangled, std::vector<ConstString> &alternates)
 {
@@ -289,8 +297,9 @@ ItaniumABILanguageRuntime::GetAlternateM
 
     alternates.clear();
     const char *mangled_cstr = mangled.AsCString();
-    for (std::map<ConstString, std::vector<ConstString> >::iterator it = s_alternate_mangling_prefixes.begin();
-         it != s_alternate_mangling_prefixes.end();
+    std::map<ConstString, std::vector<ConstString> >& alternate_mangling_prefixes = GetAlternateManglingPrefixes();
+    for (std::map<ConstString, std::vector<ConstString> >::iterator it = alternate_mangling_prefixes.begin();
+         it != alternate_mangling_prefixes.end();
          ++it)
     {
         const char *prefix_cstr = it->first.AsCString();
@@ -315,9 +324,6 @@ ItaniumABILanguageRuntime::GetAlternateM
 //------------------------------------------------------------------
 // Static Functions
 //------------------------------------------------------------------
-
-std::map<ConstString, std::vector<ConstString> > ItaniumABILanguageRuntime::s_alternate_mangling_prefixes;
-
 LanguageRuntime *
 ItaniumABILanguageRuntime::CreateInstance (Process *process, lldb::LanguageType language)
 {
@@ -343,9 +349,11 @@ ItaniumABILanguageRuntime::Initialize()
     std::vector<ConstString> basic_string_alternates;
     basic_string_alternates.push_back(ConstString("_ZNSs"));
     basic_string_alternates.push_back(ConstString("_ZNKSs"));
-    s_alternate_mangling_prefixes[ConstString("_ZNSbIcSt17char_traits<char>St15allocator<char>E")] =
+    std::map<ConstString, std::vector<ConstString> >& alternate_mangling_prefixes = GetAlternateManglingPrefixes();
+
+    alternate_mangling_prefixes[ConstString("_ZNSbIcSt17char_traits<char>St15allocator<char>E")] =
         basic_string_alternates;
-    s_alternate_mangling_prefixes[ConstString("_ZNKSbIcSt17char_traits<char>St15allocator<char>E")] =
+    alternate_mangling_prefixes[ConstString("_ZNKSbIcSt17char_traits<char>St15allocator<char>E")] =
         basic_string_alternates;
 }
 

Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h?rev=235142&r1=235141&r2=235142&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h Thu Apr 16 18:10:22 2015
@@ -103,8 +103,6 @@ namespace lldb_private {
         ItaniumABILanguageRuntime(Process *process) : lldb_private::CPPLanguageRuntime(process) { } // Call CreateInstance instead.
         
         lldb::BreakpointSP                              m_cxx_exception_bp_sp;
-
-        static std::map<ConstString, std::vector<ConstString> > s_alternate_mangling_prefixes;
     };
     
 } // namespace lldb_private





More information about the lldb-commits mailing list