[Lldb-commits] [lldb] d017d12 - [lldb][NFC] Cleanup IRForTarget member initializers

Shafik Yaghmour via lldb-commits lldb-commits at lists.llvm.org
Tue May 18 10:41:15 PDT 2021


If you are doing further clean-up here, it almost looks like those two reference members could actually be owned by IRForTarget i.e.

  m_execution_unit
  m_error_stream

Which would be cleaner. 

> On May 18, 2021, at 1:49 AM, Raphael Isemann via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> 
> 
> Author: Raphael Isemann
> Date: 2021-05-18T10:49:11+02:00
> New Revision: d017d12f126ee9045f58f9300078d805e3bcc763
> 
> URL: https://github.com/llvm/llvm-project/commit/d017d12f126ee9045f58f9300078d805e3bcc763
> DIFF: https://github.com/llvm/llvm-project/commit/d017d12f126ee9045f58f9300078d805e3bcc763.diff
> 
> LOG: [lldb][NFC] Cleanup IRForTarget member initializers
> 
> Note that the FunctionCallee members aren't pointer, so the nullptr was just
> an alternative way to call the default constructor.
> 
> Added: 
> 
> 
> Modified: 
>    lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
>    lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
> 
> Removed: 
> 
> 
> 
> ################################################################################
> diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
> index b35bf07034bdc..0173c8f263a5b 100644
> --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
> +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
> @@ -73,12 +73,8 @@ IRForTarget::IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map,
>                          lldb_private::Stream &error_stream,
>                          const char *func_name)
>     : ModulePass(ID), m_resolve_vars(resolve_vars), m_func_name(func_name),
> -      m_module(nullptr), m_decl_map(decl_map),
> -      m_CFStringCreateWithBytes(nullptr), m_sel_registerName(nullptr),
> -      m_objc_getClass(nullptr), m_intptr_ty(nullptr),
> -      m_error_stream(error_stream), m_execution_unit(execution_unit),
> -      m_result_store(nullptr), m_result_is_pointer(false),
> -      m_reloc_placeholder(nullptr),
> +      m_decl_map(decl_map), m_error_stream(error_stream),
> +      m_execution_unit(execution_unit),
>       m_entry_instruction_finder(FindEntryInstruction) {}
> 
> /* Handy utility functions used at several places in the code */
> 
> diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
> index ebfc0cae626cb..6ff50ec5f645c 100644
> --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
> +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.h
> @@ -419,51 +419,46 @@ class IRForTarget : public llvm::ModulePass {
>   ///     True on success; false otherwise
>   bool ReplaceVariables(llvm::Function &llvm_function);
> 
> -  /// Flags
> -  bool m_resolve_vars; ///< True if external variable references and persistent
> -                       ///variable references should be resolved
> -  lldb_private::ConstString
> -      m_func_name; ///< The name of the function to translate
> -  lldb_private::ConstString
> -      m_result_name; ///< The name of the result variable ($0, $1, ...)
> -  lldb_private::TypeFromParser
> -      m_result_type;      ///< The type of the result variable.
> -  llvm::Module *m_module; ///< The module being processed, or NULL if that has
> -                          ///not been determined yet.
> -  std::unique_ptr<llvm::DataLayout> m_target_data; ///< The target data for the
> -                                                   ///module being processed, or
> -                                                   ///NULL if there is no
> -                                                   ///module.
> -  lldb_private::ClangExpressionDeclMap
> -      *m_decl_map; ///< The DeclMap containing the Decls
> -  llvm::FunctionCallee
> -      m_CFStringCreateWithBytes; ///< The address of the function
> -                                 /// CFStringCreateWithBytes, cast to the
> -                                 /// appropriate function pointer type
> -  llvm::FunctionCallee m_sel_registerName; ///< The address of the function
> -                                           /// sel_registerName, cast to the
> -                                           /// appropriate function pointer type
> -  llvm::FunctionCallee m_objc_getClass; ///< The address of the function
> -                                        /// objc_getClass, cast to the
> -                                        /// appropriate function pointer type
> -  llvm::IntegerType
> -      *m_intptr_ty; ///< The type of an integer large enough to hold a pointer.
> -  lldb_private::Stream
> -      &m_error_stream; ///< The stream on which errors should be printed
> -  lldb_private::IRExecutionUnit &
> -      m_execution_unit; ///< The execution unit containing the IR being created.
> -
> -  llvm::StoreInst *m_result_store; ///< If non-NULL, the store instruction that
> -                                   ///writes to the result variable.  If
> -                                   /// m_has_side_effects is true, this is
> -                                   /// NULL.
> -  bool m_result_is_pointer; ///< True if the function's result in the AST is a
> -                            ///pointer (see comments in
> -                            /// ASTResultSynthesizer::SynthesizeBodyResult)
> -
> +  /// True if external variable references and persistent variable references
> +  /// should be resolved
> +  bool m_resolve_vars;
> +  /// The name of the function to translate
> +  lldb_private::ConstString m_func_name;
> +  /// The name of the result variable ($0, $1, ...)
> +  lldb_private::ConstString m_result_name;
> +  /// The type of the result variable.
> +  lldb_private::TypeFromParser m_result_type;
> +  /// The module being processed, or NULL if that has not been determined yet.
> +  llvm::Module *m_module = nullptr;
> +  /// The target data for the module being processed, or NULL if there is no
> +  /// module.
> +  std::unique_ptr<llvm::DataLayout> m_target_data;
> +  /// The DeclMap containing the Decls
> +  lldb_private::ClangExpressionDeclMap *m_decl_map;
> +  /// The address of the function CFStringCreateWithBytes, cast to the
> +  /// appropriate function pointer type
> +  llvm::FunctionCallee m_CFStringCreateWithBytes;
> +  /// The address of the function sel_registerName, cast to the appropriate
> +  /// function pointer type.
> +  llvm::FunctionCallee m_sel_registerName;
> +  /// The address of the function objc_getClass, cast to the appropriate
> +  /// function pointer type.
> +  llvm::FunctionCallee m_objc_getClass;
> +  /// The type of an integer large enough to hold a pointer.
> +  llvm::IntegerType *m_intptr_ty = nullptr;
> +  /// The stream on which errors should be printed.
> +  lldb_private::Stream &m_error_stream;
> +  /// The execution unit containing the IR being created.
> +  lldb_private::IRExecutionUnit &m_execution_unit;
> +  /// If non-NULL, the store instruction that writes to the result variable.  If
> +  /// m_has_side_effects is true, this is NULL.
> +  llvm::StoreInst *m_result_store = nullptr;
> +  /// True if the function's result in the AST is a pointer (see comments in
> +  /// ASTResultSynthesizer::SynthesizeBodyResult)
> +  bool m_result_is_pointer = false;
>   /// A placeholder that will be replaced by a pointer to the final location of
>   /// the static allocation.
> -  llvm::GlobalVariable *m_reloc_placeholder;
> +  llvm::GlobalVariable *m_reloc_placeholder = nullptr;
> 
>   class FunctionValueCache {
>   public:
> 
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits



More information about the lldb-commits mailing list