[Lldb-commits] [lldb] r175108 - Centralized the expression prefixes that are used for both expressions and utility functions.

Greg Clayton gclayton at apple.com
Wed Feb 13 15:57:48 PST 2013


Author: gclayton
Date: Wed Feb 13 17:57:48 2013
New Revision: 175108

URL: http://llvm.org/viewvc/llvm-project?rev=175108&view=rev
Log:
Centralized the expression prefixes that are used for both expressions and utility functions.


Modified:
    lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h
    lldb/trunk/source/Expression/ClangUtilityFunction.cpp
    lldb/trunk/source/Expression/ExpressionSourceCode.cpp

Modified: lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h?rev=175108&r1=175107&r2=175108&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h (original)
+++ lldb/trunk/include/lldb/Expression/ExpressionSourceCode.h Wed Feb 13 17:57:48 2013
@@ -20,6 +20,8 @@ namespace lldb_private
 class ExpressionSourceCode
 {
 public:
+    static const char * g_expression_prefix;
+
     static ExpressionSourceCode *CreateWrapped (const char *prefix,
                                                 const char *body)
     {

Modified: lldb/trunk/source/Expression/ClangUtilityFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUtilityFunction.cpp?rev=175108&r1=175107&r2=175108&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUtilityFunction.cpp (original)
+++ lldb/trunk/source/Expression/ClangUtilityFunction.cpp Wed Feb 13 17:57:48 2013
@@ -22,39 +22,13 @@
 #include "lldb/Expression/ClangExpressionDeclMap.h"
 #include "lldb/Expression/ClangExpressionParser.h"
 #include "lldb/Expression/ClangUtilityFunction.h"
+#include "lldb/Expression/ExpressionSourceCode.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Target.h"
 
 using namespace lldb_private;
 
-static const char *g_global_defines =
-"#undef NULL                       \n"
-"#undef Nil                        \n"
-"#undef nil                        \n"
-"#undef YES                        \n"
-"#undef NO                         \n"
-"#define NULL ((int)0)             \n"
-"#define Nil ((Class)0)            \n"
-"#define nil ((id)0)               \n"
-"#define YES ((BOOL)1)             \n"
-"#define NO ((BOOL)0)              \n"
-"typedef signed char BOOL;         \n"
-"typedef signed __INT8_TYPE__ int8_t;\n"
-"typedef unsigned __INT8_TYPE__ uint8_t;\n"
-"typedef signed __INT16_TYPE__ int16_t;\n"
-"typedef unsigned __INT16_TYPE__ uint16_t;\n"
-"typedef signed __INT32_TYPE__ int32_t;\n"
-"typedef unsigned __INT32_TYPE__ uint32_t;\n"
-"typedef signed __INT64_TYPE__ int64_t;\n"
-"typedef unsigned __INT64_TYPE__ uint64_t;\n"
-"typedef signed __INTPTR_TYPE__ intptr_t;\n"
-"typedef unsigned __INTPTR_TYPE__ uintptr_t;\n"
-"typedef __SIZE_TYPE__ size_t; \n"
-"typedef __PTRDIFF_TYPE__ ptrdiff_t;\n"
-"typedef unsigned short unichar;\n";
-
-
 //------------------------------------------------------------------
 /// Constructor
 ///
@@ -67,7 +41,7 @@ static const char *g_global_defines =
 ClangUtilityFunction::ClangUtilityFunction (const char *text, 
                                             const char *name) :
     ClangExpression (),
-    m_function_text (g_global_defines),
+    m_function_text (ExpressionSourceCode::g_expression_prefix),
     m_function_name (name)
 {
     if (text && text[0])

Modified: lldb/trunk/source/Expression/ExpressionSourceCode.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ExpressionSourceCode.cpp?rev=175108&r1=175107&r2=175108&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ExpressionSourceCode.cpp (original)
+++ lldb/trunk/source/Expression/ExpressionSourceCode.cpp Wed Feb 13 17:57:48 2013
@@ -13,31 +13,33 @@
 
 using namespace lldb_private;
 
-static const char *global_defines =
-"#undef NULL                       \n"
-"#undef Nil                        \n"
-"#undef nil                        \n"
-"#undef YES                        \n"
-"#undef NO                         \n"
-"#define NULL (__null)             \n"
-"#define Nil (__null)              \n"
-"#define nil (__null)              \n"
-"#define YES ((BOOL)1)             \n"
-"#define NO ((BOOL)0)              \n"
-"typedef signed char BOOL;         \n"
-"typedef signed __INT8_TYPE__ int8_t;\n"
-"typedef unsigned __INT8_TYPE__ uint8_t;\n"
-"typedef signed __INT16_TYPE__ int16_t;\n"
-"typedef unsigned __INT16_TYPE__ uint16_t;\n"
-"typedef signed __INT32_TYPE__ int32_t;\n"
-"typedef unsigned __INT32_TYPE__ uint32_t;\n"
-"typedef signed __INT64_TYPE__ int64_t;\n"
-"typedef unsigned __INT64_TYPE__ uint64_t;\n"
-"typedef signed __INTPTR_TYPE__ intptr_t;\n"
-"typedef unsigned __INTPTR_TYPE__ uintptr_t;\n"
-"typedef __SIZE_TYPE__ size_t; \n"
-"typedef __PTRDIFF_TYPE__ ptrdiff_t;\n"
-"typedef unsigned short unichar;\n";
+const char *
+ExpressionSourceCode::g_expression_prefix = R"(
+#undef NULL
+#undef Nil
+#undef nil
+#undef YES
+#undef NO
+#define NULL (__null)
+#define Nil (__null)
+#define nil (__null)
+#define YES ((BOOL)1)
+#define NO ((BOOL)0)
+typedef signed char BOOL;
+typedef signed __INT8_TYPE__ int8_t;
+typedef unsigned __INT8_TYPE__ uint8_t;
+typedef signed __INT16_TYPE__ int16_t;
+typedef unsigned __INT16_TYPE__ uint16_t;
+typedef signed __INT32_TYPE__ int32_t;
+typedef unsigned __INT32_TYPE__ uint32_t;
+typedef signed __INT64_TYPE__ int64_t;
+typedef unsigned __INT64_TYPE__ uint64_t;
+typedef signed __INTPTR_TYPE__ intptr_t;
+typedef unsigned __INTPTR_TYPE__ uintptr_t;
+typedef __SIZE_TYPE__ size_t;
+typedef __PTRDIFF_TYPE__ ptrdiff_t;
+typedef unsigned short unichar;
+)";
 
 
 bool ExpressionSourceCode::GetText (std::string &text, lldb::LanguageType wrapping_language, bool const_object, bool static_method) const
@@ -69,7 +71,7 @@ bool ExpressionSourceCode::GetText (std:
                                "    %s;                        \n" 
                                "}                              \n",
                                m_prefix.c_str(),
-                               global_defines,
+                               g_expression_prefix,
                                m_name.c_str(),
                                m_body.c_str());
             break;
@@ -82,7 +84,7 @@ bool ExpressionSourceCode::GetText (std:
                                "    %s;                                \n" 
                                "}                                      \n",
                                m_prefix.c_str(),
-                               global_defines,
+                               g_expression_prefix,
                                m_name.c_str(),
                                (const_object ? "const" : ""),
                                m_body.c_str());
@@ -102,7 +104,7 @@ bool ExpressionSourceCode::GetText (std:
                                    "}                                                       \n"
                                    "@end                                                    \n",
                                    m_prefix.c_str(),
-                                   global_defines,
+                                   g_expression_prefix,
                                    m_name.c_str(),
                                    m_name.c_str(),
                                    m_body.c_str());
@@ -121,7 +123,7 @@ bool ExpressionSourceCode::GetText (std:
                                    "}                                                      \n"
                                    "@end                                                   \n",
                                    m_prefix.c_str(),
-                                   global_defines,
+                                   g_expression_prefix,
                                    m_name.c_str(),
                                    m_name.c_str(),
                                    m_body.c_str());





More information about the lldb-commits mailing list