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/ClangUserExpression.h | |
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/ClangUserExpression.h')
-rw-r--r-- | lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h | 302 |
1 files changed, 142 insertions, 160 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h index 6077588b024..1aea69fd45f 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h @@ -16,26 +16,26 @@ // Other libraries and framework includes // Project includes -#include "ASTStructExtractor.h" #include "ASTResultSynthesizer.h" +#include "ASTStructExtractor.h" #include "ClangExpressionDeclMap.h" #include "ClangExpressionHelper.h" #include "ClangExpressionVariable.h" #include "IRForTarget.h" -#include "lldb/lldb-forward.h" -#include "lldb/lldb-private.h" #include "lldb/Core/Address.h" #include "lldb/Core/ClangForward.h" #include "lldb/Expression/LLVMUserExpression.h" #include "lldb/Expression/Materializer.h" #include "lldb/Target/ExecutionContext.h" +#include "lldb/lldb-forward.h" +#include "lldb/lldb-private.h" -namespace lldb_private -{ +namespace lldb_private { //---------------------------------------------------------------------- -/// @class ClangUserExpression ClangUserExpression.h "lldb/Expression/ClangUserExpression.h" +/// @class ClangUserExpression ClangUserExpression.h +/// "lldb/Expression/ClangUserExpression.h" /// @brief Encapsulates a single expression for use with Clang /// /// LLDB uses expressions for various purposes, notably to call functions @@ -43,172 +43,154 @@ namespace lldb_private /// the objects needed to parse and interpret or JIT an expression. It /// uses the Clang parser to produce LLVM IR from the expression. //---------------------------------------------------------------------- -class ClangUserExpression : public LLVMUserExpression -{ +class ClangUserExpression : public LLVMUserExpression { public: - enum { kDefaultTimeout = 500000u }; - - class ClangUserExpressionHelper : public ClangExpressionHelper - { - public: - ClangUserExpressionHelper(Target &target, bool top_level) : m_target(target), m_top_level(top_level) {} - - ~ClangUserExpressionHelper() override = default; - - //------------------------------------------------------------------ - /// Return the object that the parser should use when resolving external - /// values. May be NULL if everything should be self-contained. - //------------------------------------------------------------------ - ClangExpressionDeclMap * - DeclMap() override - { - return m_expr_decl_map_up.get(); - } - - void - ResetDeclMap() - { - m_expr_decl_map_up.reset(); - } - - void - ResetDeclMap (ExecutionContext & exe_ctx, Materializer::PersistentVariableDelegate &result_delegate, bool keep_result_in_memory); - - //------------------------------------------------------------------ - /// Return the object that the parser should allow to access ASTs. - /// May be NULL if the ASTs do not need to be transformed. - /// - /// @param[in] passthrough - /// The ASTConsumer that the returned transformer should send - /// the ASTs to after transformation. - //------------------------------------------------------------------ - clang::ASTConsumer * - ASTTransformer(clang::ASTConsumer *passthrough) override; - - void - CommitPersistentDecls() override; - - private: - Target &m_target; - std::unique_ptr<ClangExpressionDeclMap> m_expr_decl_map_up; - std::unique_ptr<ASTStructExtractor> - m_struct_extractor_up; ///< The class that generates the argument struct layout. - std::unique_ptr<ASTResultSynthesizer> m_result_synthesizer_up; - bool m_top_level; - }; + enum { kDefaultTimeout = 500000u }; + + class ClangUserExpressionHelper : public ClangExpressionHelper { + public: + ClangUserExpressionHelper(Target &target, bool top_level) + : m_target(target), m_top_level(top_level) {} + + ~ClangUserExpressionHelper() override = default; //------------------------------------------------------------------ - /// Constructor - /// - /// @param[in] expr - /// The expression to parse. - /// - /// @param[in] expr_prefix - /// If non-NULL, a C string containing translation-unit level - /// definitions to be included when the expression is parsed. - /// - /// @param[in] language - /// If not eLanguageTypeUnknown, a language to use when parsing - /// the expression. Currently restricted to those languages - /// supported by Clang. - /// - /// @param[in] desired_type - /// If not eResultTypeAny, the type to use for the expression - /// result. + /// Return the object that the parser should use when resolving external + /// values. May be NULL if everything should be self-contained. //------------------------------------------------------------------ - ClangUserExpression (ExecutionContextScope &exe_scope, - const char *expr, - const char *expr_prefix, - lldb::LanguageType language, - ResultType desired_type, - const EvaluateExpressionOptions &options); + ClangExpressionDeclMap *DeclMap() override { + return m_expr_decl_map_up.get(); + } + + void ResetDeclMap() { m_expr_decl_map_up.reset(); } - ~ClangUserExpression() override; + void ResetDeclMap(ExecutionContext &exe_ctx, + Materializer::PersistentVariableDelegate &result_delegate, + bool keep_result_in_memory); //------------------------------------------------------------------ - /// Parse the expression - /// - /// @param[in] diagnostic_manager - /// A diagnostic manager to report parse errors and warnings to. + /// Return the object that the parser should allow to access ASTs. + /// May be NULL if the ASTs do not need to be transformed. /// - /// @param[in] exe_ctx - /// The execution context to use when looking up entities that - /// are needed for parsing (locations of functions, types of - /// variables, persistent variables, etc.) - /// - /// @param[in] execution_policy - /// Determines whether interpretation is possible or mandatory. - /// - /// @param[in] keep_result_in_memory - /// True if the resulting persistent variable should reside in - /// target memory, if applicable. - /// - /// @return - /// True on success (no errors); false otherwise. + /// @param[in] passthrough + /// The ASTConsumer that the returned transformer should send + /// the ASTs to after transformation. //------------------------------------------------------------------ - bool - Parse(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, - lldb_private::ExecutionPolicy execution_policy, bool keep_result_in_memory, - bool generate_debug_info) override; - - ExpressionTypeSystemHelper * - GetTypeSystemHelper () override - { - return &m_type_system_helper; - } - - ClangExpressionDeclMap * - DeclMap () - { - return m_type_system_helper.DeclMap(); - } - - void - ResetDeclMap () - { - m_type_system_helper.ResetDeclMap(); - } - - void - ResetDeclMap (ExecutionContext & exe_ctx, Materializer::PersistentVariableDelegate &result_delegate, bool keep_result_in_memory) - { - m_type_system_helper.ResetDeclMap(exe_ctx, result_delegate, keep_result_in_memory); - } + clang::ASTConsumer * + ASTTransformer(clang::ASTConsumer *passthrough) override; + + void CommitPersistentDecls() override; + + private: + Target &m_target; + std::unique_ptr<ClangExpressionDeclMap> m_expr_decl_map_up; + std::unique_ptr<ASTStructExtractor> m_struct_extractor_up; ///< The class + ///that generates + ///the argument + ///struct layout. + std::unique_ptr<ASTResultSynthesizer> m_result_synthesizer_up; + bool m_top_level; + }; + + //------------------------------------------------------------------ + /// Constructor + /// + /// @param[in] expr + /// The expression to parse. + /// + /// @param[in] expr_prefix + /// If non-NULL, a C string containing translation-unit level + /// definitions to be included when the expression is parsed. + /// + /// @param[in] language + /// If not eLanguageTypeUnknown, a language to use when parsing + /// the expression. Currently restricted to those languages + /// supported by Clang. + /// + /// @param[in] desired_type + /// If not eResultTypeAny, the type to use for the expression + /// result. + //------------------------------------------------------------------ + ClangUserExpression(ExecutionContextScope &exe_scope, const char *expr, + const char *expr_prefix, lldb::LanguageType language, + ResultType desired_type, + const EvaluateExpressionOptions &options); + + ~ClangUserExpression() override; + + //------------------------------------------------------------------ + /// Parse the expression + /// + /// @param[in] diagnostic_manager + /// A diagnostic manager to report parse errors and warnings to. + /// + /// @param[in] exe_ctx + /// The execution context to use when looking up entities that + /// are needed for parsing (locations of functions, types of + /// variables, persistent variables, etc.) + /// + /// @param[in] execution_policy + /// Determines whether interpretation is possible or mandatory. + /// + /// @param[in] keep_result_in_memory + /// True if the resulting persistent variable should reside in + /// target memory, if applicable. + /// + /// @return + /// True on success (no errors); false otherwise. + //------------------------------------------------------------------ + bool Parse(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx, + lldb_private::ExecutionPolicy execution_policy, + bool keep_result_in_memory, bool generate_debug_info) override; + + ExpressionTypeSystemHelper *GetTypeSystemHelper() override { + return &m_type_system_helper; + } + + ClangExpressionDeclMap *DeclMap() { return m_type_system_helper.DeclMap(); } + + void ResetDeclMap() { m_type_system_helper.ResetDeclMap(); } + + void ResetDeclMap(ExecutionContext &exe_ctx, + Materializer::PersistentVariableDelegate &result_delegate, + bool keep_result_in_memory) { + m_type_system_helper.ResetDeclMap(exe_ctx, result_delegate, + keep_result_in_memory); + } + + lldb::ExpressionVariableSP + GetResultAfterDematerialization(ExecutionContextScope *exe_scope) override; - lldb::ExpressionVariableSP - GetResultAfterDematerialization(ExecutionContextScope *exe_scope) override; - private: - //------------------------------------------------------------------ - /// Populate m_in_cplusplus_method and m_in_objectivec_method based on the environment. - //------------------------------------------------------------------ + //------------------------------------------------------------------ + /// Populate m_in_cplusplus_method and m_in_objectivec_method based on the + /// environment. + //------------------------------------------------------------------ + + void ScanContext(ExecutionContext &exe_ctx, + lldb_private::Error &err) override; + + bool AddArguments(ExecutionContext &exe_ctx, std::vector<lldb::addr_t> &args, + lldb::addr_t struct_address, + DiagnosticManager &diagnostic_manager) override; + + ClangUserExpressionHelper m_type_system_helper; + + class ResultDelegate : public Materializer::PersistentVariableDelegate { + public: + ResultDelegate(); + ConstString GetName() override; + void DidDematerialize(lldb::ExpressionVariableSP &variable) override; + + void RegisterPersistentState(PersistentExpressionState *persistent_state); + lldb::ExpressionVariableSP &GetVariable(); + + private: + PersistentExpressionState *m_persistent_state; + lldb::ExpressionVariableSP m_variable; + }; - void - ScanContext (ExecutionContext &exe_ctx, - lldb_private::Error &err) override; - - bool - AddArguments(ExecutionContext &exe_ctx, std::vector<lldb::addr_t> &args, lldb::addr_t struct_address, - DiagnosticManager &diagnostic_manager) override; - - ClangUserExpressionHelper m_type_system_helper; - - class ResultDelegate : public Materializer::PersistentVariableDelegate - { - public: - ResultDelegate(); - ConstString GetName() override; - void DidDematerialize(lldb::ExpressionVariableSP &variable) override; - - void RegisterPersistentState(PersistentExpressionState *persistent_state); - lldb::ExpressionVariableSP &GetVariable(); - - private: - PersistentExpressionState *m_persistent_state; - lldb::ExpressionVariableSP m_variable; - }; - - ResultDelegate m_result_delegate; + ResultDelegate m_result_delegate; }; } // namespace lldb_private |