diff options
author | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
---|---|---|
committer | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
commit | b9c1b51e45b845debb76d8658edabca70ca56079 (patch) | |
tree | dfcb5a13ef2b014202340f47036da383eaee74aa /lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp | |
parent | d5aa73376966339caad04013510626ec2e42c760 (diff) | |
download | bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip |
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
Diffstat (limited to 'lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp')
-rw-r--r-- | lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp | 210 |
1 files changed, 96 insertions, 114 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp index 727e4b3329b..d3af620145b 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp @@ -1,4 +1,5 @@ -//===-- ClangUserExpression.cpp -------------------------------------*- C++ -*-===// +//===-- ClangUserExpression.cpp -------------------------------------*- C++ +//-*-===// // // The LLVM Compiler Infrastructure // @@ -7,14 +8,14 @@ // //===----------------------------------------------------------------------===// +#include "ClangUtilityFunction.h" #include "ClangExpressionDeclMap.h" #include "ClangExpressionParser.h" -#include "ClangUtilityFunction.h" // C Includes #include <stdio.h> #if HAVE_SYS_TYPES_H -# include <sys/types.h> +#include <sys/types.h> #endif // C++ Includes @@ -41,16 +42,11 @@ using namespace lldb_private; /// @param[in] name /// The name of the function, as used in the text. //------------------------------------------------------------------ -ClangUtilityFunction::ClangUtilityFunction (ExecutionContextScope &exe_scope, - const char *text, - const char *name) : - UtilityFunction (exe_scope, text, name) -{ -} +ClangUtilityFunction::ClangUtilityFunction(ExecutionContextScope &exe_scope, + const char *text, const char *name) + : UtilityFunction(exe_scope, text, name) {} -ClangUtilityFunction::~ClangUtilityFunction () -{ -} +ClangUtilityFunction::~ClangUtilityFunction() {} //------------------------------------------------------------------ /// Install the utility function into a process @@ -64,94 +60,85 @@ ClangUtilityFunction::~ClangUtilityFunction () /// @return /// True on success (no errors); false otherwise. //------------------------------------------------------------------ -bool -ClangUtilityFunction::Install(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx) -{ - if (m_jit_start_addr != LLDB_INVALID_ADDRESS) - { - diagnostic_manager.PutCString(eDiagnosticSeverityWarning, "already installed"); - return false; - } +bool ClangUtilityFunction::Install(DiagnosticManager &diagnostic_manager, + ExecutionContext &exe_ctx) { + if (m_jit_start_addr != LLDB_INVALID_ADDRESS) { + diagnostic_manager.PutCString(eDiagnosticSeverityWarning, + "already installed"); + return false; + } - //////////////////////////////////// - // Set up the target and compiler - // - - Target *target = exe_ctx.GetTargetPtr(); + //////////////////////////////////// + // Set up the target and compiler + // - if (!target) - { - diagnostic_manager.PutCString(eDiagnosticSeverityError, "invalid target"); - return false; - } + Target *target = exe_ctx.GetTargetPtr(); - Process *process = exe_ctx.GetProcessPtr(); + if (!target) { + diagnostic_manager.PutCString(eDiagnosticSeverityError, "invalid target"); + return false; + } - if (!process) - { - diagnostic_manager.PutCString(eDiagnosticSeverityError, "invalid process"); - return false; - } + Process *process = exe_ctx.GetProcessPtr(); - ////////////////////////// - // Parse the expression - // - - bool keep_result_in_memory = false; - - ResetDeclMap(exe_ctx, keep_result_in_memory); - - if (!DeclMap()->WillParse(exe_ctx, NULL)) - { - diagnostic_manager.PutCString(eDiagnosticSeverityError, - "current process state is unsuitable for expression parsing"); - return false; - } + if (!process) { + diagnostic_manager.PutCString(eDiagnosticSeverityError, "invalid process"); + return false; + } - const bool generate_debug_info = true; - ClangExpressionParser parser(exe_ctx.GetBestExecutionContextScope(), *this, generate_debug_info); + ////////////////////////// + // Parse the expression + // - unsigned num_errors = parser.Parse(diagnostic_manager); + bool keep_result_in_memory = false; - if (num_errors) - { - ResetDeclMap(); + ResetDeclMap(exe_ctx, keep_result_in_memory); - return false; - } - - ////////////////////////////////// - // JIT the output of the parser - // - - bool can_interpret = false; // should stay that way - - Error jit_error = parser.PrepareForExecution (m_jit_start_addr, - m_jit_end_addr, - m_execution_unit_sp, - exe_ctx, - can_interpret, - eExecutionPolicyAlways); - - if (m_jit_start_addr != LLDB_INVALID_ADDRESS) - { - m_jit_process_wp = process->shared_from_this(); - if (parser.GetGenerateDebugInfo()) - { - lldb::ModuleSP jit_module_sp ( m_execution_unit_sp->GetJITModule()); - - if (jit_module_sp) - { - ConstString const_func_name(FunctionName()); - FileSpec jit_file; - jit_file.GetFilename() = const_func_name; - jit_module_sp->SetFileSpecAndObjectName (jit_file, ConstString()); - m_jit_module_wp = jit_module_sp; - target->GetImages().Append(jit_module_sp); - } - } + if (!DeclMap()->WillParse(exe_ctx, NULL)) { + diagnostic_manager.PutCString( + eDiagnosticSeverityError, + "current process state is unsuitable for expression parsing"); + return false; + } + + const bool generate_debug_info = true; + ClangExpressionParser parser(exe_ctx.GetBestExecutionContextScope(), *this, + generate_debug_info); + + unsigned num_errors = parser.Parse(diagnostic_manager); + + if (num_errors) { + ResetDeclMap(); + + return false; + } + + ////////////////////////////////// + // JIT the output of the parser + // + + bool can_interpret = false; // should stay that way + + Error jit_error = parser.PrepareForExecution( + m_jit_start_addr, m_jit_end_addr, m_execution_unit_sp, exe_ctx, + can_interpret, eExecutionPolicyAlways); + + if (m_jit_start_addr != LLDB_INVALID_ADDRESS) { + m_jit_process_wp = process->shared_from_this(); + if (parser.GetGenerateDebugInfo()) { + lldb::ModuleSP jit_module_sp(m_execution_unit_sp->GetJITModule()); + + if (jit_module_sp) { + ConstString const_func_name(FunctionName()); + FileSpec jit_file; + jit_file.GetFilename() = const_func_name; + jit_module_sp->SetFileSpecAndObjectName(jit_file, ConstString()); + m_jit_module_wp = jit_module_sp; + target->GetImages().Append(jit_module_sp); + } } - + } + #if 0 // jingham: look here StreamFile logfile ("/tmp/exprs.txt", "a"); @@ -161,31 +148,26 @@ ClangUtilityFunction::Install(DiagnosticManager &diagnostic_manager, ExecutionCo m_function_text.c_str()); #endif - DeclMap()->DidParse(); - - ResetDeclMap(); - - if (jit_error.Success()) - { - return true; - } - else - { - const char *error_cstr = jit_error.AsCString(); - if (error_cstr && error_cstr[0]) - { - diagnostic_manager.Printf(eDiagnosticSeverityError, "%s", error_cstr); - } - else - { - diagnostic_manager.PutCString(eDiagnosticSeverityError, "expression can't be interpreted or run"); - } - return false; + DeclMap()->DidParse(); + + ResetDeclMap(); + + if (jit_error.Success()) { + return true; + } else { + const char *error_cstr = jit_error.AsCString(); + if (error_cstr && error_cstr[0]) { + diagnostic_manager.Printf(eDiagnosticSeverityError, "%s", error_cstr); + } else { + diagnostic_manager.PutCString(eDiagnosticSeverityError, + "expression can't be interpreted or run"); } + return false; + } } -void -ClangUtilityFunction::ClangUtilityFunctionHelper::ResetDeclMap(ExecutionContext &exe_ctx, bool keep_result_in_memory) -{ - m_expr_decl_map_up.reset(new ClangExpressionDeclMap(keep_result_in_memory, nullptr, exe_ctx)); +void ClangUtilityFunction::ClangUtilityFunctionHelper::ResetDeclMap( + ExecutionContext &exe_ctx, bool keep_result_in_memory) { + m_expr_decl_map_up.reset( + new ClangExpressionDeclMap(keep_result_in_memory, nullptr, exe_ctx)); } |