[Lldb-commits] [lldb] r264347 - Get rid of two global constructors by making things static variables in the only function that uses these variables.

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 24 14:48:10 PDT 2016


Author: gclayton
Date: Thu Mar 24 16:48:10 2016
New Revision: 264347

URL: http://llvm.org/viewvc/llvm-project?rev=264347&view=rev
Log:
Get rid of two global constructors by making things static variables in the only function that uses these variables.


Modified:
    lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
    lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h

Modified: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=264347&r1=264346&r2=264347&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp Thu Mar 24 16:48:10 2016
@@ -757,8 +757,6 @@ const uint32_t RenderScriptRuntime::Allo
     {eFormatVectorOfFloat32, eFormatVectorOfFloat32, sizeof(float) * 4}   // RS_TYPE_MATRIX_2X2
 };
 
-const std::string RenderScriptRuntime::s_runtimeExpandSuffix(".expand");
-const std::array<const char *, 3> RenderScriptRuntime::s_runtimeCoordVars{{"rsIndex", "p->current.y", "p->current.z"}};
 //------------------------------------------------------------------
 // Static Functions
 //------------------------------------------------------------------
@@ -3267,6 +3265,9 @@ RenderScriptRuntime::GetFrameVarAsUnsign
 bool
 RenderScriptRuntime::GetKernelCoordinate(RSCoordinate &coord, Thread *thread_ptr)
 {
+    static const std::string s_runtimeExpandSuffix(".expand");
+    static const std::array<const char *, 3> s_runtimeCoordVars{{"rsIndex", "p->current.y", "p->current.z"}};
+
     Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE));
 
     if (!thread_ptr)
@@ -3299,13 +3300,13 @@ RenderScriptRuntime::GetKernelCoordinate
 
         // Check if function name has .expand suffix
         std::string func_name(func_name_cstr);
-        const int length_difference = func_name.length() - RenderScriptRuntime::s_runtimeExpandSuffix.length();
+        const int length_difference = func_name.length() - s_runtimeExpandSuffix.length();
         if (length_difference <= 0)
             continue;
 
         const int32_t has_expand_suffix = func_name.compare(length_difference,
-                                                            RenderScriptRuntime::s_runtimeExpandSuffix.length(),
-                                                            RenderScriptRuntime::s_runtimeExpandSuffix);
+                                                            s_runtimeExpandSuffix.length(),
+                                                            s_runtimeExpandSuffix);
 
         if (has_expand_suffix != 0)
             continue;
@@ -3315,12 +3316,12 @@ RenderScriptRuntime::GetKernelCoordinate
 
         // Get values for variables in .expand frame that tell us the current kernel invocation
         bool found_coord_variables = true;
-        assert(RenderScriptRuntime::s_runtimeCoordVars.size() == coord.size());
+        assert(s_runtimeCoordVars.size() == coord.size());
 
         for (uint32_t i = 0; i < coord.size(); ++i)
         {
             uint64_t value = 0;
-            if (!GetFrameVarAsUnsigned(frame_sp, RenderScriptRuntime::s_runtimeCoordVars[i], value))
+            if (!GetFrameVarAsUnsigned(frame_sp, s_runtimeCoordVars[i], value))
             {
                 found_coord_variables = false;
                 break;

Modified: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h?rev=264347&r1=264346&r2=264347&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h Thu Mar 24 16:48:10 2016
@@ -321,8 +321,6 @@ protected:
     bool m_breakAllKernels;
     static const HookDefn s_runtimeHookDefns[];
     static const size_t s_runtimeHookCount;
-    static const std::string s_runtimeExpandSuffix;
-    static const std::array<const char *, 3> s_runtimeCoordVars;
 
 private:
     RenderScriptRuntime(Process *process); // Call CreateInstance instead.




More information about the lldb-commits mailing list