Made Target own a ClangASTSource that will be used
to complete types in the scratch AST context.


git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@144712 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index 866810c..022cdb3 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -26,6 +26,7 @@
 #include "lldb/Core/StreamString.h"
 #include "lldb/Core/Timer.h"
 #include "lldb/Core/ValueObject.h"
+#include "lldb/Expression/ClangASTSource.h"
 #include "lldb/Expression/ClangUserExpression.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Interpreter/CommandInterpreter.h"
@@ -171,6 +172,7 @@
     m_search_filter_sp.reset();
     m_image_search_paths.Clear(notify);
     m_scratch_ast_context_ap.reset();
+    m_scratch_ast_source_ap.reset();
     m_persistent_variables.Clear();
     m_stop_hooks.clear();
     m_stop_hook_next_id = 0;
@@ -794,6 +796,7 @@
 {
     m_images.Clear();
     m_scratch_ast_context_ap.reset();
+    m_scratch_ast_source_ap.reset();
     
     if (executable_sp.get())
     {
@@ -1329,7 +1332,13 @@
 {
     // Now see if we know the target triple, and if so, create our scratch AST context:
     if (m_scratch_ast_context_ap.get() == NULL && m_arch.IsValid())
+    {
         m_scratch_ast_context_ap.reset (new ClangASTContext(m_arch.GetTriple().str().c_str()));
+        m_scratch_ast_source_ap.reset (new ClangASTSource(GetSP()));
+        m_scratch_ast_source_ap->InstallASTContext(m_scratch_ast_context_ap->getASTContext());
+        llvm::OwningPtr<clang::ExternalASTSource> proxy_ast_source(m_scratch_ast_source_ap->CreateProxy());
+        m_scratch_ast_context_ap->SetExternalSource(proxy_ast_source);
+    }
     return m_scratch_ast_context_ap.get();
 }