From d01b4a786271c9ce9df43add56ec2e3fb40ce920 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Tue, 1 Oct 2019 12:28:14 +0000 Subject: [PATCH] [lldb][NFC] Modernize ClangASTContext constructor Now using default initializers and StringRef. Also formats the member list that we excluded from clang-format at some point and still hangs around with the old LLDB code style. llvm-svn: 373329 --- lldb/include/lldb/Symbol/ClangASTContext.h | 59 +++++++++++++++--------------- lldb/source/Symbol/ClangASTContext.cpp | 17 +++------ 2 files changed, 35 insertions(+), 41 deletions(-) diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h index 8777634..d0928f4 100644 --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -52,7 +52,7 @@ public: } // Constructors and Destructors - ClangASTContext(const char *triple = nullptr); + ClangASTContext(llvm::StringRef triple = ""); ~ClangASTContext() override; @@ -110,7 +110,7 @@ public: const char *GetTargetTriple(); - void SetTargetTriple(const char *target_triple); + void SetTargetTriple(llvm::StringRef target_triple); void SetArchitecture(const ArchSpec &arch); @@ -978,34 +978,33 @@ protected: GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type); // Classes that inherit from ClangASTContext can see and modify these - // clang-format off - std::string m_target_triple; - std::unique_ptr m_ast_up; - std::unique_ptr m_language_options_up; - std::unique_ptr m_file_manager_up; - std::unique_ptr m_source_manager_up; - std::unique_ptr m_diagnostics_engine_up; - std::unique_ptr m_diagnostic_consumer_up; - std::shared_ptr m_target_options_rp; - std::unique_ptr m_target_info_up; - std::unique_ptr m_identifier_table_up; - std::unique_ptr m_selector_table_up; - std::unique_ptr m_builtins_up; - std::unique_ptr m_dwarf_ast_parser_up; - std::unique_ptr m_pdb_ast_parser_up; - std::unique_ptr m_scratch_ast_source_up; - std::unique_ptr m_mangle_ctx_up; - CompleteTagDeclCallback m_callback_tag_decl; - CompleteObjCInterfaceDeclCallback m_callback_objc_decl; - void * m_callback_baton; - clang::ExternalASTMerger::OriginMap m_origins; - uint32_t m_pointer_byte_size; - bool m_ast_owned; - /// The sema associated that is currently used to build this ASTContext. - /// May be null if we are already done parsing this ASTContext or the - /// ASTContext wasn't created by parsing source code. - clang::Sema * m_sema = nullptr; - // clang-format on + std::string m_target_triple; + std::unique_ptr m_ast_up; + std::unique_ptr m_language_options_up; + std::unique_ptr m_file_manager_up; + std::unique_ptr m_source_manager_up; + std::unique_ptr m_diagnostics_engine_up; + std::unique_ptr m_diagnostic_consumer_up; + std::shared_ptr m_target_options_rp; + std::unique_ptr m_target_info_up; + std::unique_ptr m_identifier_table_up; + std::unique_ptr m_selector_table_up; + std::unique_ptr m_builtins_up; + std::unique_ptr m_dwarf_ast_parser_up; + std::unique_ptr m_pdb_ast_parser_up; + std::unique_ptr m_scratch_ast_source_up; + std::unique_ptr m_mangle_ctx_up; + CompleteTagDeclCallback m_callback_tag_decl = nullptr; + CompleteObjCInterfaceDeclCallback m_callback_objc_decl = nullptr; + void *m_callback_baton = nullptr; + clang::ExternalASTMerger::OriginMap m_origins; + uint32_t m_pointer_byte_size = 0; + bool m_ast_owned = false; + /// The sema associated that is currently used to build this ASTContext. + /// May be null if we are already done parsing this ASTContext or the + /// ASTContext wasn't created by parsing source code. + clang::Sema *m_sema = nullptr; + private: // For ClangASTContext only ClangASTContext(const ClangASTContext &); diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 78bad39..891410d 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -522,14 +522,9 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) { Opts.NoInlineDefine = !Opt; } -ClangASTContext::ClangASTContext(const char *target_triple) - : TypeSystem(TypeSystem::eKindClang), m_target_triple(), m_ast_up(), - m_language_options_up(), m_source_manager_up(), m_diagnostics_engine_up(), - m_target_options_rp(), m_target_info_up(), m_identifier_table_up(), - m_selector_table_up(), m_builtins_up(), m_callback_tag_decl(nullptr), - m_callback_objc_decl(nullptr), m_callback_baton(nullptr), - m_pointer_byte_size(0), m_ast_owned(false) { - if (target_triple && target_triple[0]) +ClangASTContext::ClangASTContext(llvm::StringRef target_triple) + : TypeSystem(TypeSystem::eKindClang) { + if (!target_triple.empty()) SetTargetTriple(target_triple); } @@ -676,13 +671,13 @@ const char *ClangASTContext::GetTargetTriple() { return m_target_triple.c_str(); } -void ClangASTContext::SetTargetTriple(const char *target_triple) { +void ClangASTContext::SetTargetTriple(llvm::StringRef target_triple) { Clear(); - m_target_triple.assign(target_triple); + m_target_triple = target_triple.str(); } void ClangASTContext::SetArchitecture(const ArchSpec &arch) { - SetTargetTriple(arch.GetTriple().str().c_str()); + SetTargetTriple(arch.GetTriple().str()); } bool ClangASTContext::HasExternalSource() { -- 2.7.4