[Lldb-commits] [lldb] r373329 - [lldb][NFC] Modernize ClangASTContext constructor

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 1 05:28:14 PDT 2019


Author: teemperor
Date: Tue Oct  1 05:28:14 2019
New Revision: 373329

URL: http://llvm.org/viewvc/llvm-project?rev=373329&view=rev
Log:
[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.

Modified:
    lldb/trunk/include/lldb/Symbol/ClangASTContext.h
    lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=373329&r1=373328&r2=373329&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Oct  1 05:28:14 2019
@@ -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<clang::ASTContext>              m_ast_up;
-    std::unique_ptr<clang::LangOptions>             m_language_options_up;
-    std::unique_ptr<clang::FileManager>             m_file_manager_up;
-    std::unique_ptr<clang::SourceManager>           m_source_manager_up;
-    std::unique_ptr<clang::DiagnosticsEngine>       m_diagnostics_engine_up;
-    std::unique_ptr<clang::DiagnosticConsumer>      m_diagnostic_consumer_up;
-    std::shared_ptr<clang::TargetOptions>           m_target_options_rp;
-    std::unique_ptr<clang::TargetInfo>              m_target_info_up;
-    std::unique_ptr<clang::IdentifierTable>         m_identifier_table_up;
-    std::unique_ptr<clang::SelectorTable>           m_selector_table_up;
-    std::unique_ptr<clang::Builtin::Context>        m_builtins_up;
-    std::unique_ptr<DWARFASTParserClang>            m_dwarf_ast_parser_up;
-    std::unique_ptr<PDBASTParser>                   m_pdb_ast_parser_up;
-    std::unique_ptr<ClangASTSource>                 m_scratch_ast_source_up;
-    std::unique_ptr<clang::MangleContext>           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<clang::ASTContext> m_ast_up;
+  std::unique_ptr<clang::LangOptions> m_language_options_up;
+  std::unique_ptr<clang::FileManager> m_file_manager_up;
+  std::unique_ptr<clang::SourceManager> m_source_manager_up;
+  std::unique_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_up;
+  std::unique_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_up;
+  std::shared_ptr<clang::TargetOptions> m_target_options_rp;
+  std::unique_ptr<clang::TargetInfo> m_target_info_up;
+  std::unique_ptr<clang::IdentifierTable> m_identifier_table_up;
+  std::unique_ptr<clang::SelectorTable> m_selector_table_up;
+  std::unique_ptr<clang::Builtin::Context> m_builtins_up;
+  std::unique_ptr<DWARFASTParserClang> m_dwarf_ast_parser_up;
+  std::unique_ptr<PDBASTParser> m_pdb_ast_parser_up;
+  std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
+  std::unique_ptr<clang::MangleContext> 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 &);

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=373329&r1=373328&r2=373329&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Oct  1 05:28:14 2019
@@ -522,14 +522,9 @@ static void ParseLangArgs(LangOptions &O
   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::GetTargetTr
   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() {




More information about the lldb-commits mailing list