[Lldb-commits] [lldb] r144838 - in /lldb/trunk: include/lldb/Symbol/ClangASTImporter.h source/Symbol/ClangASTImporter.cpp

Sean Callanan scallanan at apple.com
Wed Nov 16 14:23:29 PST 2011


Author: spyffe
Date: Wed Nov 16 16:23:28 2011
New Revision: 144838

URL: http://llvm.org/viewvc/llvm-project?rev=144838&view=rev
Log:
Added support to the ASTImporter for passing
completion information between different AST
contexts.  It works like this:

- If a Decl is imported from a context that
  has completion metadata, then that Decl
  is associated with the same completion
  information (possibly none) as the Decl
  it was imported from.

- If a Decl is imported from a context that
  does not have completion metadata, then it
  is marked as completable by consulting the
  Decl and context it was imported from.

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

Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTImporter.h?rev=144838&r1=144837&r2=144838&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTImporter.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Wed Nov 16 16:23:28 2011
@@ -211,6 +211,17 @@
         }
     }
     
+    ASTContextMetadataSP
+    MaybeGetContextMetadata (clang::ASTContext *dst_ctx)
+    {
+        ContextMetadataMap::iterator context_md_iter = m_metadata_map.find(dst_ctx);
+
+        if (context_md_iter != m_metadata_map.end())
+            return context_md_iter->second;
+        else
+            return ASTContextMetadataSP();
+    }
+    
     MinionSP
     GetMinion (clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx)
     {

Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=144838&r1=144837&r2=144838&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Wed Nov 16 16:23:28 2011
@@ -194,10 +194,35 @@
 {
     lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     
-    ASTContextMetadataSP context_md = m_master.GetContextMetadata(&to->getASTContext());
+    ASTContextMetadataSP to_context_md = m_master.GetContextMetadata(&to->getASTContext());
+    ASTContextMetadataSP from_context_md = m_master.MaybeGetContextMetadata(m_source_ctx);
     
-    context_md->m_origins[to] = DeclOrigin (m_source_ctx, from);
- 
+    if (from_context_md)
+    {
+        OriginMap &origins = from_context_md->m_origins;
+        
+        OriginMap::iterator origin_iter = origins.find(from);
+        
+        if (origin_iter != origins.end())
+            to_context_md->m_origins[to] = origin_iter->second;
+        
+        if (clang::NamespaceDecl *to_namespace = dyn_cast<clang::NamespaceDecl>(to))
+        {
+            clang::NamespaceDecl *from_namespace = dyn_cast<clang::NamespaceDecl>(from);
+            
+            NamespaceMetaMap &namespace_maps = from_context_md->m_namespace_maps;
+            
+            NamespaceMetaMap::iterator namespace_map_iter = namespace_maps.find(from_namespace);
+            
+            if (namespace_map_iter != namespace_maps.end())
+                to_context_md->m_namespace_maps[to_namespace] = namespace_map_iter->second;
+        }
+    }
+    else
+    {
+        to_context_md->m_origins[to] = DeclOrigin (m_source_ctx, from);
+    }
+        
     if (TagDecl *from_tag_decl = dyn_cast<TagDecl>(from))
     {
         TagDecl *to_tag_decl = dyn_cast<TagDecl>(to);





More information about the lldb-commits mailing list