[Lldb-commits] [lldb] r245376 - More abstraction to get almost all clang specific DWARF parsing code into ClangASTContext.

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 18 15:32:36 PDT 2015


Author: gclayton
Date: Tue Aug 18 17:32:36 2015
New Revision: 245376

URL: http://llvm.org/viewvc/llvm-project?rev=245376&view=rev
Log:
More abstraction to get almost all clang specific DWARF parsing code into ClangASTContext.


Modified:
    lldb/trunk/include/lldb/Symbol/ClangASTContext.h
    lldb/trunk/include/lldb/Symbol/SymbolFile.h
    lldb/trunk/include/lldb/Symbol/TypeSystem.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
    lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
    lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
    lldb/trunk/source/Symbol/ClangASTContext.cpp
    lldb/trunk/source/Symbol/Type.cpp
    lldb/trunk/source/Symbol/TypeSystem.cpp

Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=245376&r1=245375&r2=245376&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Aug 18 17:32:36 2015
@@ -525,21 +525,29 @@ public:
                             const DWARFDebugInfoEntry *die) override;
 
     bool
-    ResolveClangOpaqueTypeDefinition (SymbolFileDWARF *dwarf,
-                                      DWARFCompileUnit *dwarf_cu,
-                                      const DWARFDebugInfoEntry* die,
-                                      Type *type,
-                                      CompilerType &clang_type) override;
+    CompleteTypeFromDWARF (SymbolFileDWARF *dwarf,
+                           DWARFCompileUnit *dwarf_cu,
+                           const DWARFDebugInfoEntry* die,
+                           lldb_private::Type *type,
+                           CompilerType &clang_type) override;
 
-    bool
-    LayoutRecordType (SymbolFileDWARF *dwarf,
-                      const clang::RecordDecl *record_decl,
-                      uint64_t &bit_size,
-                      uint64_t &alignment,
-                      llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
-                      llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
-                      llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets) override;
+    //------------------------------------------------------------------
+    // ClangASTContext callbacks for external source lookups.
+    //------------------------------------------------------------------
+    static void
+    CompleteTagDecl (void *baton, clang::TagDecl *);
+
+    static void
+    CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *);
 
+    static bool
+    LayoutRecordType(void *baton,
+                     const clang::RecordDecl *record_decl,
+                     uint64_t &size,
+                     uint64_t &alignment,
+                     llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
+                     llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
+                     llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets);
 
     bool
     DIEIsInNamespace (const ClangNamespaceDecl *namespace_decl,
@@ -1204,6 +1212,30 @@ protected:
                                 DWARFCompileUnit* dst_cu,
                                 const DWARFDebugInfoEntry *dst_class_die,
                                 DWARFDIECollection &failures);
+
+    clang::DeclContext *
+    GetCachedClangDeclContextForDIE (const DWARFDebugInfoEntry *die)
+    {
+        DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die);
+        if (pos != m_die_to_decl_ctx.end())
+            return pos->second;
+        else
+            return NULL;
+    }
+
+    void
+    LinkDeclContextToDIE (clang::DeclContext *decl_ctx,
+                          const DWARFDebugInfoEntry *die)
+    {
+        m_die_to_decl_ctx[die] = decl_ctx;
+        // There can be many DIEs for a single decl context
+        m_decl_ctx_to_die[decl_ctx].insert(die);
+    }
+
+    typedef llvm::SmallPtrSet<const DWARFDebugInfoEntry *, 4> DIEPointerSet;
+    typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap;
+    typedef llvm::DenseMap<const clang::DeclContext *, DIEPointerSet> DeclContextToDIEMap;
+
     //------------------------------------------------------------------
     // Classes that inherit from ClangASTContext can see and modify these
     //------------------------------------------------------------------
@@ -1225,7 +1257,13 @@ protected:
     void *                                          m_callback_baton;
     uint32_t                                        m_pointer_byte_size;
     bool                                            m_ast_owned;
+    // DWARF Parsing related ivars
     RecordDeclToLayoutMap                           m_record_decl_to_layout_map;
+    DIEToDeclContextMap                             m_die_to_decl_ctx;
+    DeclContextToDIEMap                             m_decl_ctx_to_die;
+    clang::TranslationUnitDecl *                    m_clang_tu_decl;
+
+
 
 private:
     //------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=245376&r1=245375&r2=245376&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Tue Aug 18 17:32:36 2015
@@ -129,7 +129,7 @@ public:
     virtual size_t          ParseTypes (const SymbolContext& sc) = 0;
     virtual size_t          ParseVariablesForContext (const SymbolContext& sc) = 0;
     virtual Type*           ResolveTypeUID (lldb::user_id_t type_uid) = 0;
-    virtual bool            ResolveClangOpaqueTypeDefinition (CompilerType &clang_type) = 0;
+    virtual bool            CompleteType (CompilerType &clang_type) = 0;
     virtual clang::DeclContext* GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid) { return NULL; }
     virtual clang::DeclContext* GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid) { return NULL; }
     virtual uint32_t        ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) = 0;

Modified: lldb/trunk/include/lldb/Symbol/TypeSystem.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeSystem.h?rev=245376&r1=245375&r2=245376&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/TypeSystem.h (original)
+++ lldb/trunk/include/lldb/Symbol/TypeSystem.h Tue Aug 18 17:32:36 2015
@@ -56,20 +56,27 @@ public:
                             const DWARFDebugInfoEntry *die) = 0;
 
     virtual bool
-    ResolveClangOpaqueTypeDefinition (SymbolFileDWARF *dwarf,
-                                      DWARFCompileUnit *dwarf_cu,
-                                      const DWARFDebugInfoEntry* die,
-                                      Type *type,
-                                      CompilerType &clang_type) = 0;
+    CompleteTypeFromDWARF (SymbolFileDWARF *dwarf,
+                           DWARFCompileUnit *dwarf_cu,
+                           const DWARFDebugInfoEntry* die,
+                           lldb_private::Type *type,
+                           CompilerType &clang_type)
+    {
+        return false;
+    }
 
-    virtual bool
-    LayoutRecordType (SymbolFileDWARF *dwarf,
-                      const clang::RecordDecl *record_decl,
-                      uint64_t &bit_size,
-                      uint64_t &alignment,
-                      llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
-                      llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
-                      llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets) = 0;
+    virtual SymbolFile *
+    GetSymbolFile () const
+    {
+        return m_sym_file;
+    }
+
+    // Returns true if the symbol file changed during the set accessor.
+    virtual void
+    SetSymbolFile (SymbolFile *sym_file)
+    {
+        m_sym_file = sym_file;
+    }
 
     virtual bool
     DIEIsInNamespace (const ClangNamespaceDecl *namespace_decl,
@@ -401,6 +408,9 @@ public:
     
     virtual bool
     IsReferenceType (void * type, CompilerType *pointee_type, bool* is_rvalue) = 0;
+protected:
+    SymbolFile *m_sym_file;
+
 };
     
 } // namespace lldb_private

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=245376&r1=245375&r2=245376&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Aug 18 17:32:36 2015
@@ -3118,12 +3118,12 @@
 				260C89D710F57C5600BB2B04 /* DWARFLocationList.cpp */,
 				260C89D810F57C5600BB2B04 /* DWARFLocationList.h */,
 				26A0DA4D140F721D006DA411 /* HashedNameToDIE.h */,
+				26109B3B1155D70100CC3529 /* LogChannelDWARF.cpp */,
+				26109B3C1155D70100CC3529 /* LogChannelDWARF.h */,
 				2618D9EA12406FE600F2B8FE /* NameToDIE.cpp */,
 				2618D957124056C700F2B8FE /* NameToDIE.h */,
 				260C89D910F57C5600BB2B04 /* SymbolFileDWARF.cpp */,
 				260C89DA10F57C5600BB2B04 /* SymbolFileDWARF.h */,
-				26109B3B1155D70100CC3529 /* LogChannelDWARF.cpp */,
-				26109B3C1155D70100CC3529 /* LogChannelDWARF.h */,
 				260C89DB10F57C5600BB2B04 /* SymbolFileDWARFDebugMap.cpp */,
 				260C89DC10F57C5600BB2B04 /* SymbolFileDWARFDebugMap.h */,
 				26B8B42212EEC52A00A831B2 /* UniqueDWARFASTType.h */,

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=245376&r1=245375&r2=245376&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Aug 18 17:32:36 2015
@@ -48,7 +48,6 @@
 #include "lldb/Interpreter/OptionValueProperties.h"
 
 #include "lldb/Symbol/Block.h"
-#include "lldb/Symbol/ClangExternalASTSourceCallbacks.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/LineTable.h"
 #include "lldb/Symbol/ObjectFile.h"
@@ -504,7 +503,6 @@ SymbolFileDWARF::SymbolFileDWARF(ObjectF
     UserID (0),  // Used by SymbolFileDWARFDebugMap to when this class parses .o files to contain the .o file index/ID
     m_debug_map_module_wp (),
     m_debug_map_symfile (NULL),
-    m_clang_tu_decl (NULL),
     m_flags(),
     m_data_debug_abbrev (),
     m_data_debug_aranges (),
@@ -533,7 +531,6 @@ SymbolFileDWARF::SymbolFileDWARF(ObjectF
     m_type_index(),
     m_namespace_index(),
     m_indexed (false),
-    m_is_external_ast_source (false),
     m_using_apple_tables (false),
     m_fetched_external_modules (false),
     m_supports_DW_AT_APPLE_objc_complete_type (eLazyBoolCalculate),
@@ -544,12 +541,6 @@ SymbolFileDWARF::SymbolFileDWARF(ObjectF
 
 SymbolFileDWARF::~SymbolFileDWARF()
 {
-    if (m_is_external_ast_source)
-    {
-        ModuleSP module_sp (m_obj_file->GetModule());
-        if (module_sp)
-            module_sp->GetClangASTContext().RemoveExternalSource ();
-    }
 }
 
 static const ConstString &
@@ -572,20 +563,8 @@ SymbolFileDWARF::GetClangASTContext ()
 {
     if (GetDebugMapSymfile ())
         return m_debug_map_symfile->GetClangASTContext ();
-
-    ClangASTContext &ast = m_obj_file->GetModule()->GetClangASTContext();
-    if (!m_is_external_ast_source)
-    {
-        m_is_external_ast_source = true;
-        llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source_ap (
-            new ClangExternalASTSourceCallbacks (SymbolFileDWARF::CompleteTagDecl,
-                                                 SymbolFileDWARF::CompleteObjCInterfaceDecl,
-                                                 SymbolFileDWARF::FindExternalVisibleDeclsByName,
-                                                 SymbolFileDWARF::LayoutRecordType,
-                                                 this));
-        ast.SetExternalSource (ast_source_ap);
-    }
-    return ast;
+    else
+        return m_obj_file->GetModule()->GetClangASTContext();
 }
 
 TypeSystem *
@@ -595,22 +574,12 @@ SymbolFileDWARF::GetTypeSystemForLanguag
     if (debug_map_symfile)
         return debug_map_symfile->GetTypeSystemForLanguage (language);
     else
-    {
-        TypeSystem *type_system = m_obj_file->GetModule()->GetTypeSystemForLanguage (language);
-
-        if (type_system && type_system->AsClangASTContext())
-        {
-            // Get the ClangAST so that we register the ClangExternalASTSource callbacks if needed...
-            GetClangASTContext();
-        }
-        return type_system;
-    }
+        return m_obj_file->GetModule()->GetTypeSystemForLanguage (language);
 }
 
 void
 SymbolFileDWARF::InitializeObject()
 {
-    // Install our external AST source callbacks so we can complete Clang types.
     ModuleSP module_sp (m_obj_file->GetModule());
     if (module_sp)
     {
@@ -661,6 +630,12 @@ SymbolFileDWARF::InitializeObject()
         else
             m_apple_objc_ap.reset();
     }
+
+    // Set the symbol file to this file if we don't have a debug map symbol
+    // file as our main symbol file. This allows the clang ASTContext to complete
+    // types using this symbol file when it needs to complete classes and structures.
+    if (GetDebugMapSymfile () == nullptr)
+        GetClangASTContext().SetSymbolFile(this);
 }
 
 bool
@@ -1588,7 +1563,7 @@ SymbolFileDWARF::HasForwardDeclForClangT
 
 
 bool
-SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (CompilerType &clang_type)
+SymbolFileDWARF::CompleteType (CompilerType &clang_type)
 {
     // We have a struct/union/class/enum that needs to be fully resolved.
     CompilerType clang_type_no_qualifiers = ClangASTContext::RemoveFastQualifiers(clang_type);
@@ -1604,19 +1579,7 @@ SymbolFileDWARF::ResolveClangOpaqueTypeD
     // are done.
     m_forward_decl_clang_type_to_die.erase (clang_type_no_qualifiers.GetOpaqueQualType());
 
-    ClangASTContext* ast = clang_type.GetTypeSystem()->AsClangASTContext();
-    if (ast == NULL)
-    {
-        // Not a clang type
-        return true;
-    }
-    
-    // Disable external storage for this type so we don't get anymore 
-    // clang::ExternalASTSource queries for this type.
-    ast->SetHasExternalStorage (clang_type.GetOpaqueQualType(), false);
-
     DWARFDebugInfo* debug_info = DebugInfo();
-
     DWARFCompileUnit *dwarf_cu = debug_info->GetCompileUnitContainingDIE (die->GetOffset()).get();
     Type *type = m_die_to_type.lookup (die);
 
@@ -1634,7 +1597,7 @@ SymbolFileDWARF::ResolveClangOpaqueTypeD
     TypeSystem *type_system = GetTypeSystemForLanguage(dwarf_cu->GetLanguageType());
 
     if (type_system)
-        return type_system->ResolveClangOpaqueTypeDefinition(this, dwarf_cu, die, type, clang_type);
+        return type_system->CompleteTypeFromDWARF (this, dwarf_cu, die, type, clang_type);
 
     return false;
 }
@@ -4577,24 +4540,6 @@ SymbolFileDWARF::GetPluginVersion()
 }
 
 void
-SymbolFileDWARF::CompleteTagDecl (void *baton, clang::TagDecl *decl)
-{
-    SymbolFileDWARF *symbol_file_dwarf = (SymbolFileDWARF *)baton;
-    CompilerType clang_type = symbol_file_dwarf->GetClangASTContext().GetTypeForDecl (decl);
-    if (clang_type)
-        symbol_file_dwarf->ResolveClangOpaqueTypeDefinition (clang_type);
-}
-
-void
-SymbolFileDWARF::CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *decl)
-{
-    SymbolFileDWARF *symbol_file_dwarf = (SymbolFileDWARF *)baton;
-    CompilerType clang_type = symbol_file_dwarf->GetClangASTContext().GetTypeForDecl (decl);
-    if (clang_type)
-        symbol_file_dwarf->ResolveClangOpaqueTypeDefinition (clang_type);
-}
-
-void
 SymbolFileDWARF::DumpIndexes ()
 {
     StreamFile s(stdout, false);
@@ -4612,111 +4557,6 @@ SymbolFileDWARF::DumpIndexes ()
     s.Printf("\nNamespaces:\n");            m_namespace_index.Dump (&s);
 }
 
-void
-SymbolFileDWARF::SearchDeclContext (const clang::DeclContext *decl_context, 
-                                    const char *name, 
-                                    llvm::SmallVectorImpl <clang::NamedDecl *> *results)
-{    
-    DeclContextToDIEMap::iterator iter = m_decl_ctx_to_die.find(decl_context);
-    
-    if (iter == m_decl_ctx_to_die.end())
-        return;
-    
-    for (DIEPointerSet::iterator pos = iter->second.begin(), end = iter->second.end(); pos != end; ++pos)
-    {
-        const DWARFDebugInfoEntry *context_die = *pos;
-    
-        if (!results)
-            return;
-        
-        DWARFDebugInfo* info = DebugInfo();
-        
-        DIEArray die_offsets;
-        
-        DWARFCompileUnit* dwarf_cu = NULL;
-        const DWARFDebugInfoEntry* die = NULL;
-        
-        if (m_using_apple_tables)
-        {
-            if (m_apple_types_ap.get())
-                m_apple_types_ap->FindByName (name, die_offsets);
-        }
-        else
-        {
-            if (!m_indexed)
-                Index ();
-            
-            m_type_index.Find (ConstString(name), die_offsets);
-        }
-        
-        const size_t num_matches = die_offsets.size();
-        
-        if (num_matches)
-        {
-            for (size_t i = 0; i < num_matches; ++i)
-            {
-                const dw_offset_t die_offset = die_offsets[i];
-                die = info->GetDIEPtrWithCompileUnitHint (die_offset, &dwarf_cu);
-
-                if (die->GetParent() != context_die)
-                    continue;
-                
-                Type *matching_type = ResolveType (dwarf_cu, die);
-                
-                clang::QualType qual_type = ClangASTContext::GetQualType(matching_type->GetClangForwardType());
-                
-                if (const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr()))
-                {
-                    clang::TagDecl *tag_decl = tag_type->getDecl();
-                    results->push_back(tag_decl);
-                }
-                else if (const clang::TypedefType *typedef_type = llvm::dyn_cast<clang::TypedefType>(qual_type.getTypePtr()))
-                {
-                    clang::TypedefNameDecl *typedef_decl = typedef_type->getDecl();
-                    results->push_back(typedef_decl); 
-                }
-            }
-        }
-    }
-}
-
-void
-SymbolFileDWARF::FindExternalVisibleDeclsByName (void *baton,
-                                                 const clang::DeclContext *decl_context,
-                                                 clang::DeclarationName decl_name,
-                                                 llvm::SmallVectorImpl <clang::NamedDecl *> *results)
-{
-    
-    switch (decl_context->getDeclKind())
-    {
-    case clang::Decl::Namespace:
-    case clang::Decl::TranslationUnit:
-        {
-            SymbolFileDWARF *symbol_file_dwarf = (SymbolFileDWARF *)baton;
-            symbol_file_dwarf->SearchDeclContext (decl_context, decl_name.getAsString().c_str(), results);
-        }
-        break;
-    default:
-        break;
-    }
-}
-
-bool
-SymbolFileDWARF::LayoutRecordType(void *baton, const clang::RecordDecl *record_decl, uint64_t &size,
-                                  uint64_t &alignment,
-                                  llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
-                                  llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
-                                  llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets)
-{
-    if (baton)
-    {
-        SymbolFileDWARF *symbol_file_dwarf = (SymbolFileDWARF *)baton;
-        TypeSystem *type_system = symbol_file_dwarf->GetTypeSystemForLanguage(eLanguageTypeC_plus_plus);
-        if (type_system)
-            return type_system->LayoutRecordType (symbol_file_dwarf, record_decl, size, alignment, field_offsets, base_offsets, vbase_offsets);
-    }
-    return false;
-}
 
 SymbolFileDWARFDebugMap *
 SymbolFileDWARF::GetDebugMapSymfile ()

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=245376&r1=245375&r2=245376&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Tue Aug 18 17:32:36 2015
@@ -115,7 +115,7 @@ public:
     size_t          ParseVariablesForContext (const lldb_private::SymbolContext& sc) override;
 
     lldb_private::Type* ResolveTypeUID(lldb::user_id_t type_uid) override;
-    bool            ResolveClangOpaqueTypeDefinition (lldb_private::CompilerType& clang_type) override;
+    bool            CompleteType (lldb_private::CompilerType& clang_type) override;
 
     lldb_private::Type* ResolveType (DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry* type_die, bool assert_not_being_parsed = true);
     lldb_private::Type* GetCachedTypeForDIE (const DWARFDebugInfoEntry* type_die) const;
@@ -149,26 +149,6 @@ public:
 
 
     //------------------------------------------------------------------
-    // ClangASTContext callbacks for external source lookups.
-    //------------------------------------------------------------------
-    static void
-    CompleteTagDecl (void *baton, clang::TagDecl *);
-    
-    static void
-    CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *);
-    
-    static void
-    FindExternalVisibleDeclsByName (void *baton,
-                                    const clang::DeclContext *DC,
-                                    clang::DeclarationName Name,
-                                    llvm::SmallVectorImpl <clang::NamedDecl *> *results);
-
-    static bool LayoutRecordType(void *baton, const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment,
-                                 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
-                                 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
-                                 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets);
-
-    //------------------------------------------------------------------
     // PluginInterface protocol
     //------------------------------------------------------------------
     lldb_private::ConstString
@@ -208,24 +188,9 @@ public:
     static bool
     SupportedVersion(uint16_t version);
 
-    clang::DeclContext *
-    GetCachedClangDeclContextForDIE (const DWARFDebugInfoEntry *die)
-    {
-        DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die);
-        if (pos != m_die_to_decl_ctx.end())
-            return pos->second;
-        else
-            return NULL;
-    }
-
     const DWARFDebugInfoEntry *
     GetDeclContextDIEContainingDIE (const DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die);
 
-    void
-    SearchDeclContext (const clang::DeclContext *decl_context, 
-                       const char *name, 
-                       llvm::SmallVectorImpl <clang::NamedDecl *> *results);
-    
     lldb_private::Flags&
     GetFlags ()
     {
@@ -400,14 +365,6 @@ protected:
     
     UniqueDWARFASTTypeMap &
     GetUniqueDWARFASTTypeMap ();
-
-    void                    LinkDeclContextToDIE (clang::DeclContext *decl_ctx,
-                                                  const DWARFDebugInfoEntry *die)
-                            {
-                                m_die_to_decl_ctx[die] = decl_ctx;
-                                // There can be many DIEs for a single decl context
-                                m_decl_ctx_to_die[decl_ctx].insert(die);
-                            }
     
     bool
     UserIDMatches (lldb::user_id_t uid) const
@@ -457,7 +414,6 @@ protected:
 
     lldb::ModuleWP                        m_debug_map_module_wp;
     SymbolFileDWARFDebugMap *             m_debug_map_symfile;
-    clang::TranslationUnitDecl *          m_clang_tu_decl;
     lldb_private::Flags                   m_flags;
     lldb_private::DWARFDataExtractor      m_dwarf_data; 
     lldb_private::DWARFDataExtractor      m_data_debug_abbrev;
@@ -493,22 +449,16 @@ protected:
     NameToDIE                           m_type_index;               // All type DIE offsets
     NameToDIE                           m_namespace_index;          // All type DIE offsets
     bool                                m_indexed:1,
-                                        m_is_external_ast_source:1,
                                         m_using_apple_tables:1,
                                         m_fetched_external_modules:1;
     lldb_private::LazyBool              m_supports_DW_AT_APPLE_objc_complete_type;
 
     std::unique_ptr<DWARFDebugRanges>     m_ranges;
     UniqueDWARFASTTypeMap m_unique_ast_type_map;
-    typedef llvm::SmallPtrSet<const DWARFDebugInfoEntry *, 4> DIEPointerSet;
-    typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap;
-    typedef llvm::DenseMap<const clang::DeclContext *, DIEPointerSet> DeclContextToDIEMap;
     typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *> DIEToTypePtr;
     typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::VariableSP> DIEToVariableSP;
     typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::clang_type_t> DIEToClangType;
     typedef llvm::DenseMap<lldb::clang_type_t, const DWARFDebugInfoEntry *> ClangTypeToDIE;
-    DIEToDeclContextMap m_die_to_decl_ctx;
-    DeclContextToDIEMap m_decl_ctx_to_die;
     DIEToTypePtr m_die_to_type;
     DIEToVariableSP m_die_to_variable_sp;
     DIEToClangType m_forward_decl_die_to_clang_type;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=245376&r1=245375&r2=245376&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Tue Aug 18 17:32:36 2015
@@ -24,7 +24,6 @@
 #endif
 #include "lldb/Core/Timer.h"
 
-#include "lldb/Symbol/ClangExternalASTSourceCallbacks.h"
 #include "lldb/Symbol/CompileUnit.h"
 #include "lldb/Symbol/LineTable.h"
 #include "lldb/Symbol/ObjectFile.h"
@@ -298,15 +297,9 @@ SymbolFileDWARFDebugMap::~SymbolFileDWAR
 void
 SymbolFileDWARFDebugMap::InitializeObject()
 {
-    // Install our external AST source callbacks so we can complete Clang types.
-    llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source_ap (
-        new ClangExternalASTSourceCallbacks (SymbolFileDWARFDebugMap::CompleteTagDecl,
-                                             SymbolFileDWARFDebugMap::CompleteObjCInterfaceDecl,
-                                             NULL,
-                                             SymbolFileDWARFDebugMap::LayoutRecordType,
-                                             this));
-
-    GetClangASTContext().SetExternalSource (ast_source_ap);
+    // Set the symbol file to this file. This allows the clang ASTContext to complete
+    // types using this symbol file when it needs to complete classes and structures.
+    GetClangASTContext().SetSymbolFile(this);
 }
 
 void
@@ -788,10 +781,22 @@ SymbolFileDWARFDebugMap::ResolveTypeUID(
 }
 
 bool
-SymbolFileDWARFDebugMap::ResolveClangOpaqueTypeDefinition (CompilerType& clang_type)
+SymbolFileDWARFDebugMap::CompleteType (CompilerType& clang_type)
 {
-    // We have a struct/union/class/enum that needs to be fully resolved.
-    return false;
+    bool success = false;
+    if (clang_type)
+    {
+        ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
+            if (oso_dwarf->HasForwardDeclForClangType (clang_type))
+            {
+                oso_dwarf->CompleteType (clang_type);
+                success = true;
+                return true;
+            }
+            return false;
+        });
+    }
+    return success;
 }
 
 uint32_t
@@ -1428,60 +1433,6 @@ SymbolFileDWARFDebugMap::SetCompileUnit
     }
 }
 
-
-void
-SymbolFileDWARFDebugMap::CompleteTagDecl (void *baton, clang::TagDecl *decl)
-{
-    SymbolFileDWARFDebugMap *symbol_file_dwarf = (SymbolFileDWARFDebugMap *)baton;
-    CompilerType clang_type = symbol_file_dwarf->GetClangASTContext().GetTypeForDecl (decl);
-    if (clang_type)
-    {
-        symbol_file_dwarf->ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
-            if (oso_dwarf->HasForwardDeclForClangType (clang_type))
-            {
-                oso_dwarf->ResolveClangOpaqueTypeDefinition (clang_type);
-                return true;
-            }
-            return false;
-        });
-    }
-}
-
-void
-SymbolFileDWARFDebugMap::CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *decl)
-{
-    SymbolFileDWARFDebugMap *symbol_file_dwarf = (SymbolFileDWARFDebugMap *)baton;
-    CompilerType clang_type = symbol_file_dwarf->GetClangASTContext().GetTypeForDecl (decl);
-    if (clang_type)
-    {
-        symbol_file_dwarf->ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
-            if (oso_dwarf->HasForwardDeclForClangType (clang_type))
-            {
-                oso_dwarf->ResolveClangOpaqueTypeDefinition (clang_type);
-                return true;
-            }
-            return false;
-        });
-    }
-}
-
-bool
-SymbolFileDWARFDebugMap::LayoutRecordType(void *baton, const clang::RecordDecl *record_decl, uint64_t &size,
-                                          uint64_t &alignment,
-                                          llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
-                                          llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
-                                          llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets)
-{
-    SymbolFileDWARFDebugMap *symbol_file_dwarf = (SymbolFileDWARFDebugMap *)baton;
-    bool laid_out = false;
-    symbol_file_dwarf->ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
-        return (laid_out = SymbolFileDWARF::LayoutRecordType (oso_dwarf, record_decl, size, alignment, field_offsets, base_offsets, vbase_offsets));
-    });
-    return laid_out;
-}
-
-
-
 clang::DeclContext*
 SymbolFileDWARFDebugMap::GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid)
 {

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h?rev=245376&r1=245375&r2=245376&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Tue Aug 18 17:32:36 2015
@@ -57,7 +57,6 @@ public:
     ~SymbolFileDWARFDebugMap () override;
 
     uint32_t        CalculateAbilities () override;
-
     void            InitializeObject() override;
 
     //------------------------------------------------------------------
@@ -78,7 +77,7 @@ public:
     lldb_private::Type* ResolveTypeUID (lldb::user_id_t type_uid) override;
     clang::DeclContext* GetClangDeclContextContainingTypeUID (lldb::user_id_t type_uid) override;
     clang::DeclContext* GetClangDeclContextForTypeUID (const lldb_private::SymbolContext &sc, lldb::user_id_t type_uid) override;
-    bool            ResolveClangOpaqueTypeDefinition (lldb_private::CompilerType& clang_type) override;
+    bool            CompleteType (lldb_private::CompilerType& clang_type) override;
     uint32_t        ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc) override;
     uint32_t        ResolveSymbolContext (const lldb_private::FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, lldb_private::SymbolContextList& sc_list) override;
     uint32_t        FindGlobalVariables (const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::VariableList& variables) override;
@@ -94,21 +93,6 @@ public:
                               uint32_t type_mask,
                               lldb_private::TypeList &type_list) override;
 
-
-    //------------------------------------------------------------------
-    // ClangASTContext callbacks for external source lookups.
-    //------------------------------------------------------------------
-    static void
-    CompleteTagDecl (void *baton, clang::TagDecl *);
-    
-    static void
-    CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *);
-
-    static bool LayoutRecordType(void *baton, const clang::RecordDecl *record_decl, uint64_t &size, uint64_t &alignment,
-                                 llvm::DenseMap<const clang::FieldDecl *, uint64_t> &field_offsets,
-                                 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
-                                 llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets);
-
     //------------------------------------------------------------------
     // PluginInterface protocol
     //------------------------------------------------------------------

Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=245376&r1=245375&r2=245376&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Tue Aug 18 17:32:36 2015
@@ -300,7 +300,7 @@ SymbolFileSymtab::ResolveTypeUID(lldb::u
 }
 
 bool
-SymbolFileSymtab::ResolveClangOpaqueTypeDefinition (lldb_private::CompilerType& clang_opaque_type)
+SymbolFileSymtab::CompleteType (lldb_private::CompilerType& clang_opaque_type)
 {
     return false;
 }

Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h?rev=245376&r1=245375&r2=245376&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h Tue Aug 18 17:32:36 2015
@@ -82,7 +82,7 @@ public:
     ResolveTypeUID(lldb::user_id_t type_uid);
 
     virtual bool
-    ResolveClangOpaqueTypeDefinition (lldb_private::CompilerType& clang_type);
+    CompleteType (lldb_private::CompilerType& clang_type);
 
     virtual uint32_t
     ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc);

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=245376&r1=245375&r2=245376&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Aug 18 17:32:36 2015
@@ -71,6 +71,7 @@
 #include "lldb/Core/UniqueCStringMap.h"
 #include "lldb/Expression/ASTDumper.h"
 #include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ClangExternalASTSourceCallbacks.h"
 #include "lldb/Symbol/ClangExternalASTSourceCommon.h"
 #include "lldb/Symbol/VerifyDecl.h"
 #include "lldb/Target/ExecutionContext.h"
@@ -293,22 +294,25 @@ ParseLangArgs (LangOptions &Opts, InputK
 
 
 ClangASTContext::ClangASTContext (const char *target_triple) :   
-    m_target_triple(),
-    m_ast_ap(),
-    m_language_options_ap(),
-    m_source_manager_ap(),
-    m_diagnostics_engine_ap(),
-    m_target_options_rp(),
-    m_target_info_ap(),
-    m_identifier_table_ap(),
-    m_selector_table_ap(),
-    m_builtins_ap(),
+    m_target_triple (),
+    m_ast_ap (),
+    m_language_options_ap (),
+    m_source_manager_ap (),
+    m_diagnostics_engine_ap (),
+    m_target_options_rp (),
+    m_target_info_ap (),
+    m_identifier_table_ap (),
+    m_selector_table_ap (),
+    m_builtins_ap (),
     m_callback_tag_decl (nullptr),
     m_callback_objc_decl (nullptr),
     m_callback_baton (nullptr),
     m_pointer_byte_size (0),
-    m_ast_owned(false)
-
+    m_ast_owned (false),
+    m_record_decl_to_layout_map (),
+    m_die_to_decl_ctx (),
+    m_decl_ctx_to_die (),
+    m_clang_tu_decl (nullptr)
 {
     if (target_triple && target_triple[0])
         SetTargetTriple (target_triple);
@@ -445,6 +449,13 @@ ClangASTContext::getASTContext()
         }
         
         GetASTMap().Insert(m_ast_ap.get(), this);
+
+        llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source_ap (new ClangExternalASTSourceCallbacks (ClangASTContext::CompleteTagDecl,
+                                                                                                               ClangASTContext::CompleteObjCInterfaceDecl,
+                                                                                                               nullptr,
+                                                                                                               ClangASTContext::LayoutRecordType,
+                                                                                                               this));
+        SetExternalSource (ast_source_ap);
     }
     return m_ast_ap.get();
 }
@@ -9076,11 +9087,11 @@ ClangASTContext::ParseClassTemplateDecl
 }
 
 bool
-ClangASTContext::ResolveClangOpaqueTypeDefinition (SymbolFileDWARF *dwarf,
-                                                   DWARFCompileUnit *dwarf_cu,
-                                                   const DWARFDebugInfoEntry* die,
-                                                   lldb_private::Type *type,
-                                                   CompilerType &clang_type)
+ClangASTContext::CompleteTypeFromDWARF (SymbolFileDWARF *dwarf,
+                                        DWARFCompileUnit *dwarf_cu,
+                                        const DWARFDebugInfoEntry* die,
+                                        lldb_private::Type *type,
+                                        CompilerType &clang_type)
 {
     // Disable external storage for this type so we don't get anymore
     // clang::ExternalASTSource queries for this type.
@@ -9298,7 +9309,7 @@ ClangASTContext::ResolveClangOpaqueTypeD
                         if (module_sp)
                         {
                             module_sp->LogMessage (log,
-                                                   "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) caching layout info for record_decl = %p, bit_size = %" PRIu64 ", alignment = %" PRIu64 ", field_offsets[%u], base_offsets[%u], vbase_offsets[%u])",
+                                                   "ClangASTContext::CompleteTypeFromDWARF (clang_type = %p) caching layout info for record_decl = %p, bit_size = %" PRIu64 ", alignment = %" PRIu64 ", field_offsets[%u], base_offsets[%u], vbase_offsets[%u])",
                                                    static_cast<void*>(clang_type.GetOpaqueQualType()),
                                                    static_cast<void*>(record_decl),
                                                    layout_info.bit_size,
@@ -9314,7 +9325,7 @@ ClangASTContext::ResolveClangOpaqueTypeD
                                 for (idx = 0, pos = layout_info.field_offsets.begin(); pos != end; ++pos, ++idx)
                                 {
                                     module_sp->LogMessage(log,
-                                                          "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) field[%u] = { bit_offset=%u, name='%s' }",
+                                                          "ClangASTContext::CompleteTypeFromDWARF (clang_type = %p) field[%u] = { bit_offset=%u, name='%s' }",
                                                           static_cast<void *>(clang_type.GetOpaqueQualType()),
                                                           idx,
                                                           static_cast<uint32_t>(pos->second),
@@ -9328,7 +9339,7 @@ ClangASTContext::ResolveClangOpaqueTypeD
                                 for (idx = 0, base_pos = layout_info.base_offsets.begin(); base_pos != base_end; ++base_pos, ++idx)
                                 {
                                     module_sp->LogMessage(log,
-                                                          "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) base[%u] = { byte_offset=%u, name='%s' }",
+                                                          "ClangASTContext::CompleteTypeFromDWARF (clang_type = %p) base[%u] = { byte_offset=%u, name='%s' }",
                                                           clang_type.GetOpaqueQualType(), idx, (uint32_t)base_pos->second.getQuantity(),
                                                           base_pos->first->getNameAsString().c_str());
                                 }
@@ -9339,7 +9350,7 @@ ClangASTContext::ResolveClangOpaqueTypeD
                                 for (idx = 0, vbase_pos = layout_info.vbase_offsets.begin(); vbase_pos != vbase_end; ++vbase_pos, ++idx)
                                 {
                                     module_sp->LogMessage(log,
-                                                          "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (clang_type = %p) vbase[%u] = { byte_offset=%u, name='%s' }",
+                                                          "ClangASTContext::CompleteTypeFromDWARF (clang_type = %p) vbase[%u] = { byte_offset=%u, name='%s' }",
                                                           static_cast<void *>(clang_type.GetOpaqueQualType()), idx,
                                                           static_cast<uint32_t>(vbase_pos->second.getQuantity()),
                                                           vbase_pos->first->getNameAsString().c_str());
@@ -9375,9 +9386,34 @@ ClangASTContext::ResolveClangOpaqueTypeD
     return false;
 }
 
+void
+ClangASTContext::CompleteTagDecl (void *baton, clang::TagDecl *decl)
+{
+    ClangASTContext *ast = (ClangASTContext *)baton;
+    SymbolFile *sym_file = ast->GetSymbolFile();
+    if (sym_file)
+    {
+        CompilerType clang_type = GetTypeForDecl (decl);
+        if (clang_type)
+            sym_file->CompleteType (clang_type);
+    }
+}
+
+void
+ClangASTContext::CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *decl)
+{
+    ClangASTContext *ast = (ClangASTContext *)baton;
+    SymbolFile *sym_file = ast->GetSymbolFile();
+    if (sym_file)
+    {
+        CompilerType clang_type = GetTypeForDecl (decl);
+        if (clang_type)
+            sym_file->CompleteType (clang_type);
+    }
+}
 
 bool
-ClangASTContext::LayoutRecordType(SymbolFileDWARF *dwarf,
+ClangASTContext::LayoutRecordType(void *baton,
                                   const clang::RecordDecl *record_decl,
                                   uint64_t &bit_size,
                                   uint64_t &alignment,
@@ -9385,18 +9421,19 @@ ClangASTContext::LayoutRecordType(Symbol
                                   llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &base_offsets,
                                   llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits> &vbase_offsets)
 {
-    RecordDeclToLayoutMap::iterator pos = m_record_decl_to_layout_map.find (record_decl);
+    ClangASTContext *ast = (ClangASTContext *)baton;
+    RecordDeclToLayoutMap::iterator pos = ast->m_record_decl_to_layout_map.find (record_decl);
     bool success = false;
     base_offsets.clear();
     vbase_offsets.clear();
-    if (pos != m_record_decl_to_layout_map.end())
+    if (pos != ast->m_record_decl_to_layout_map.end())
     {
         bit_size = pos->second.bit_size;
         alignment = pos->second.alignment;
         field_offsets.swap(pos->second.field_offsets);
         base_offsets.swap (pos->second.base_offsets);
         vbase_offsets.swap (pos->second.vbase_offsets);
-        m_record_decl_to_layout_map.erase(pos);
+        ast->m_record_decl_to_layout_map.erase(pos);
         success = true;
     }
     else
@@ -10642,7 +10679,7 @@ ClangASTContext::GetClangDeclContextForD
                                             DWARFCompileUnit *cu,
                                             const DWARFDebugInfoEntry *die)
 {
-    clang::DeclContext *clang_decl_ctx = dwarf->GetCachedClangDeclContextForDIE (die);
+    clang::DeclContext *clang_decl_ctx = GetCachedClangDeclContextForDIE (die);
     if (clang_decl_ctx)
         return clang_decl_ctx;
     // If this DIE has a specification, or an abstract origin, then trace to those.
@@ -10662,7 +10699,7 @@ ClangASTContext::GetClangDeclContextForD
     bool assert_not_being_parsed = true;
     dwarf->ResolveTypeUID (cu, die, assert_not_being_parsed);
 
-    clang_decl_ctx = dwarf->GetCachedClangDeclContextForDIE (die);
+    clang_decl_ctx = GetCachedClangDeclContextForDIE (die);
 
     return clang_decl_ctx;
 }
@@ -10709,7 +10746,7 @@ ClangASTContext::ResolveNamespaceDIE (Sy
     {
         // See if we already parsed this namespace DIE and associated it with a
         // uniqued namespace declaration
-        clang::NamespaceDecl *namespace_decl = static_cast<clang::NamespaceDecl *>(dwarf->m_die_to_decl_ctx[die]);
+        clang::NamespaceDecl *namespace_decl = static_cast<clang::NamespaceDecl *>(m_die_to_decl_ctx[die]);
         if (namespace_decl)
             return namespace_decl;
         else
@@ -10742,7 +10779,7 @@ ClangASTContext::ResolveNamespaceDIE (Sy
             }
 
             if (namespace_decl)
-                dwarf->LinkDeclContextToDIE((clang::DeclContext*)namespace_decl, die);
+                LinkDeclContextToDIE((clang::DeclContext*)namespace_decl, die);
             return namespace_decl;
         }
     }
@@ -10755,8 +10792,8 @@ ClangASTContext::GetClangDeclContextCont
                                                    const DWARFDebugInfoEntry *die,
                                                    const DWARFDebugInfoEntry **decl_ctx_die_copy)
 {
-    if (dwarf->m_clang_tu_decl == NULL)
-        dwarf->m_clang_tu_decl = getASTContext()->getTranslationUnitDecl();
+    if (m_clang_tu_decl == NULL)
+        m_clang_tu_decl = getASTContext()->getTranslationUnitDecl();
 
     const DWARFDebugInfoEntry *decl_ctx_die = dwarf->GetDeclContextDIEContainingDIE (cu, die);
 
@@ -10766,14 +10803,14 @@ ClangASTContext::GetClangDeclContextCont
     if (decl_ctx_die)
     {
 
-        SymbolFileDWARF::DIEToDeclContextMap::iterator pos = dwarf->m_die_to_decl_ctx.find (decl_ctx_die);
-        if (pos != dwarf->m_die_to_decl_ctx.end())
+        DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find (decl_ctx_die);
+        if (pos != m_die_to_decl_ctx.end())
             return pos->second;
 
         switch (decl_ctx_die->Tag())
         {
             case DW_TAG_compile_unit:
-                return dwarf->m_clang_tu_decl;
+                return m_clang_tu_decl;
 
             case DW_TAG_namespace:
                 return ResolveNamespaceDIE (dwarf, cu, decl_ctx_die);
@@ -10788,7 +10825,7 @@ ClangASTContext::GetClangDeclContextCont
                     clang::DeclContext *decl_ctx = GetDeclContextForType(type->GetClangForwardType());
                     if (decl_ctx)
                     {
-                        dwarf->LinkDeclContextToDIE (decl_ctx, decl_ctx_die);
+                        LinkDeclContextToDIE (decl_ctx, decl_ctx_die);
                         if (decl_ctx)
                             return decl_ctx;
                     }
@@ -10800,7 +10837,7 @@ ClangASTContext::GetClangDeclContextCont
                 break;
         }
     }
-    return dwarf->m_clang_tu_decl;
+    return m_clang_tu_decl;
 }
 
 
@@ -11377,7 +11414,7 @@ ClangASTContext::ParseTypeFromDWARF (con
                     // Store a forward declaration to this class type in case any
                     // parameters in any class methods need it for the clang
                     // types for function prototypes.
-                    dwarf->LinkDeclContextToDIE(GetDeclContextForType(clang_type), die);
+                    LinkDeclContextToDIE(GetDeclContextForType(clang_type), die);
                     type_sp.reset (new Type (dwarf->MakeUserID(die->GetOffset()),
                                              dwarf,
                                              type_name_const_str,
@@ -11470,7 +11507,7 @@ ClangASTContext::ParseTypeFromDWARF (con
                             // Leave this as a forward declaration until we need
                             // to know the details of the type. lldb_private::Type
                             // will automatically call the SymbolFile virtual function
-                            // "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition(Type *)"
+                            // "SymbolFileDWARF::CompleteType(Type *)"
                             // When the definition needs to be defined.
                             dwarf->m_forward_decl_die_to_clang_type[die] = clang_type.GetOpaqueQualType();
                             dwarf->m_forward_decl_clang_type_to_die[ClangASTContext::RemoveFastQualifiers(clang_type).GetOpaqueQualType()] = die;
@@ -11555,7 +11592,7 @@ ClangASTContext::ParseTypeFromDWARF (con
                             enumerator_clang_type = GetEnumerationIntegerType (clang_type.GetOpaqueQualType());
                         }
 
-                        dwarf->LinkDeclContextToDIE(ClangASTContext::GetDeclContextForType(clang_type), die);
+                        LinkDeclContextToDIE(ClangASTContext::GetDeclContextForType(clang_type), die);
 
                         type_sp.reset( new Type (dwarf->MakeUserID(die->GetOffset()),
                                                  dwarf,
@@ -11787,7 +11824,7 @@ ClangASTContext::ParseTypeFromDWARF (con
                                     type_handled = objc_method_decl != NULL;
                                     if (type_handled)
                                     {
-                                        dwarf->LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(objc_method_decl), die);
+                                        LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(objc_method_decl), die);
                                         SetMetadataAsUserID (objc_method_decl, dwarf->MakeUserID(die->GetOffset()));
                                     }
                                     else
@@ -11868,7 +11905,7 @@ ClangASTContext::ParseTypeFromDWARF (con
                                         clang::DeclContext *spec_clang_decl_ctx = GetClangDeclContextForDIE (dwarf, sc, dwarf_cu, spec_die);
                                         if (spec_clang_decl_ctx)
                                         {
-                                            dwarf->LinkDeclContextToDIE(spec_clang_decl_ctx, die);
+                                            LinkDeclContextToDIE(spec_clang_decl_ctx, die);
                                         }
                                         else
                                         {
@@ -11891,7 +11928,7 @@ ClangASTContext::ParseTypeFromDWARF (con
                                         clang::DeclContext *abs_clang_decl_ctx = GetClangDeclContextForDIE (dwarf, sc, dwarf_cu, abs_die);
                                         if (abs_clang_decl_ctx)
                                         {
-                                            dwarf->LinkDeclContextToDIE (abs_clang_decl_ctx, die);
+                                            LinkDeclContextToDIE (abs_clang_decl_ctx, die);
                                         }
                                         else
                                         {
@@ -11947,7 +11984,7 @@ ClangASTContext::ParseTypeFromDWARF (con
 
                                                     if (type_handled)
                                                     {
-                                                        dwarf->LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(cxx_method_decl), die);
+                                                        LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(cxx_method_decl), die);
 
                                                         Host::SetCrashDescription (NULL);
 
@@ -12028,7 +12065,7 @@ ClangASTContext::ParseTypeFromDWARF (con
                             //                            }
                             // Add the decl to our DIE to decl context map
                             assert (function_decl);
-                            dwarf->LinkDeclContextToDIE(function_decl, die);
+                            LinkDeclContextToDIE(function_decl, die);
                             if (!function_param_decls.empty())
                                 SetFunctionParameters (function_decl,
                                                        &function_param_decls.front(),
@@ -12401,14 +12438,14 @@ ClangASTContext::CopyUniqueClassMethodTy
             src_die = src_name_to_die.GetValueAtIndexUnchecked (idx);
             dst_die = dst_name_to_die.GetValueAtIndexUnchecked (idx);
 
-            clang::DeclContext *src_decl_ctx = src_symfile->m_die_to_decl_ctx[src_die];
+            clang::DeclContext *src_decl_ctx = src_symfile->GetClangASTContext().m_die_to_decl_ctx[src_die];
             if (src_decl_ctx)
             {
                 if (log)
                     log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x",
                                  static_cast<void*>(src_decl_ctx),
                                  src_die->GetOffset(), dst_die->GetOffset());
-                dst_symfile->LinkDeclContextToDIE (src_decl_ctx, dst_die);
+                dst_symfile->GetClangASTContext().LinkDeclContextToDIE (src_decl_ctx, dst_die);
             }
             else
             {
@@ -12452,7 +12489,7 @@ ClangASTContext::CopyUniqueClassMethodTy
 
                 if (src_die && (src_die->Tag() == dst_die->Tag()))
                 {
-                    clang::DeclContext *src_decl_ctx = src_symfile->m_die_to_decl_ctx[src_die];
+                    clang::DeclContext *src_decl_ctx = src_symfile->GetClangASTContext().m_die_to_decl_ctx[src_die];
                     if (src_decl_ctx)
                     {
                         if (log)
@@ -12460,7 +12497,7 @@ ClangASTContext::CopyUniqueClassMethodTy
                                          static_cast<void*>(src_decl_ctx),
                                          src_die->GetOffset(),
                                          dst_die->GetOffset());
-                        dst_symfile->LinkDeclContextToDIE (src_decl_ctx, dst_die);
+                        dst_symfile->GetClangASTContext().LinkDeclContextToDIE (src_decl_ctx, dst_die);
                     }
                     else
                     {
@@ -12514,14 +12551,14 @@ ClangASTContext::CopyUniqueClassMethodTy
             if (dst_die)
             {
                 // Both classes have the artificial types, link them
-                clang::DeclContext *src_decl_ctx = dst_symfile->m_die_to_decl_ctx[src_die];
+                clang::DeclContext *src_decl_ctx = dst_symfile->GetClangASTContext().m_die_to_decl_ctx[src_die];
                 if (src_decl_ctx)
                 {
                     if (log)
                         log->Printf ("uniquing decl context %p from 0x%8.8x for 0x%8.8x",
                                      static_cast<void*>(src_decl_ctx),
                                      src_die->GetOffset(), dst_die->GetOffset());
-                    dst_symfile->LinkDeclContextToDIE (src_decl_ctx, dst_die);
+                    dst_symfile->GetClangASTContext().LinkDeclContextToDIE (src_decl_ctx, dst_die);
                 }
                 else
                 {

Modified: lldb/trunk/source/Symbol/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=245376&r1=245375&r2=245376&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Type.cpp (original)
+++ lldb/trunk/source/Symbol/Type.cpp Tue Aug 18 17:32:36 2015
@@ -611,7 +611,7 @@ Type::ResolveClangType (ResolveState cla
             if (!m_clang_type.IsDefined ())
             {
                 // We have a forward declaration, we need to resolve it to a complete definition.
-                m_symbol_file->ResolveClangOpaqueTypeDefinition (m_clang_type);
+                m_symbol_file->CompleteType (m_clang_type);
             }
         }
     }

Modified: lldb/trunk/source/Symbol/TypeSystem.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/TypeSystem.cpp?rev=245376&r1=245375&r2=245376&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/TypeSystem.cpp (original)
+++ lldb/trunk/source/Symbol/TypeSystem.cpp Tue Aug 18 17:32:36 2015
@@ -10,7 +10,8 @@
 
 using namespace lldb_private;
 
-TypeSystem::TypeSystem()
+TypeSystem::TypeSystem() :
+    m_sym_file (nullptr)
 {
 }
 




More information about the lldb-commits mailing list