Fixed some problems with type deportation:

  - made sure we tell Clang not to try to
    complete the type since it can't be
    completed from its origin any more; and

  - fixed a silly bug where we tried to
    forget about the original decl's origins
    rather than the deported decl's origin.

These produced some crashes in ptr_refs,
especially under libgmalloc.

<rdar://problem/13256150>

llvm-svn: 176233
diff --git a/lldb/source/Symbol/ClangASTImporter.cpp b/lldb/source/Symbol/ClangASTImporter.cpp
index 2a0aa8a..0e810cf 100644
--- a/lldb/source/Symbol/ClangASTImporter.cpp
+++ b/lldb/source/Symbol/ClangASTImporter.cpp
@@ -126,11 +126,20 @@
                               clang::ASTContext *src_ctx,
                               clang::Decl *decl)
 {
+    lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
+    
+    if (log)
+        log->Printf("    [ClangASTImporter] DeportDecl called on (%sDecl*)%p from (ASTContext*)%p to (ASTContex*)%p",
+                    decl->getDeclKindName(),
+                    decl,
+                    src_ctx,
+                    dst_ctx);
+    
     clang::Decl *result = CopyDecl(dst_ctx, src_ctx, decl);
     
     if (!result)
         return NULL;
-    
+        
     ClangASTContext::GetCompleteDecl (src_ctx, decl);
 
     MinionSP minion_sp (GetMinion (dst_ctx, src_ctx));
@@ -140,12 +149,25 @@
     
     ASTContextMetadataSP to_context_md = GetContextMetadata(dst_ctx);
 
-    OriginMap::iterator oi = to_context_md->m_origins.find(decl);
+    OriginMap::iterator oi = to_context_md->m_origins.find(result);
     
     if (oi != to_context_md->m_origins.end() &&
         oi->second.ctx == src_ctx)
         to_context_md->m_origins.erase(oi);
     
+    if (TagDecl *result_tag_decl = dyn_cast<TagDecl>(result))
+    {
+        result_tag_decl->setHasExternalLexicalStorage(false);
+        result_tag_decl->setHasExternalVisibleStorage(false);
+    }
+    
+    if (log)
+        log->Printf("    [ClangASTImporter] DeportDecl deported (%sDecl*)%p to (%sDecl*)%p",
+                    decl->getDeclKindName(),
+                    decl,
+                    result->getDeclKindName(),
+                    result);
+    
     return result;
 }