Move some functions from DWARFASTParserClang to ClangASTImporter.

This allows these functions to be re-used by a forthcoming
PDBASTParser.  The functions in question are CanCompleteType,
CompleteType, and CanImport.  Conceptually, these functions belong
on ClangASTImporter anyway, and previously they were just ping
ponging around through a few levels of indirection to end up there
as well, so this patch actually makes the code somewhat simpler.

A few methods were moved to a new file called ClangUtil, so that
they can be shared between ClangASTImporter and ClangASTContext
without creating a circular dependency between those two cpp
files.

Differential Revision: http://reviews.llvm.org/D18381

llvm-svn: 264685
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp
index 9763106..0b81994 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp
@@ -11,6 +11,7 @@
 
 #include "lldb/Core/Log.h"
 #include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ClangUtil.h"
 #include "lldb/Symbol/CompilerType.h"
 
 #include "llvm/Support/raw_ostream.h"
@@ -83,7 +84,7 @@
 
 ASTDumper::ASTDumper (const CompilerType &compiler_type)
 {
-    m_dump = ClangASTContext::GetQualType(compiler_type).getAsString();
+    m_dump = ClangUtil::GetQualType(compiler_type).getAsString();
 }
 
 
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 7d8cedf..7a3b16e 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -12,12 +12,11 @@
 #include "ASTDumper.h"
 #include "ClangModulesDeclVendor.h"
 
-#include "clang/AST/ASTContext.h"
-#include "clang/AST/RecordLayout.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ClangUtil.h"
 #include "lldb/Symbol/CompilerDeclContext.h"
 #include "lldb/Symbol/Function.h"
 #include "lldb/Symbol/SymbolFile.h"
@@ -25,6 +24,8 @@
 #include "lldb/Symbol/TaggedASTType.h"
 #include "lldb/Target/ObjCLanguageRuntime.h"
 #include "lldb/Target/Target.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/RecordLayout.h"
 
 #include <vector>
 
@@ -277,7 +278,7 @@
                     if (!clang_type)
                         continue;
 
-                    const TagType *tag_type = ClangASTContext::GetQualType(clang_type)->getAs<TagType>();
+                    const TagType *tag_type = ClangUtil::GetQualType(clang_type)->getAs<TagType>();
 
                     if (!tag_type)
                         continue;
@@ -317,7 +318,7 @@
                 if (!clang_type)
                     continue;
 
-                const TagType *tag_type = ClangASTContext::GetQualType(clang_type)->getAs<TagType>();
+                const TagType *tag_type = ClangUtil::GetQualType(clang_type)->getAs<TagType>();
 
                 if (!tag_type)
                     continue;
@@ -1905,7 +1906,8 @@
 
     SetImportInProgress(true);
 
-    QualType copied_qual_type = m_ast_importer_sp->CopyType (m_ast_context, src_ast->getASTContext(), ClangASTContext::GetQualType(src_type));
+    QualType copied_qual_type =
+        m_ast_importer_sp->CopyType(m_ast_context, src_ast->getASTContext(), ClangUtil::GetQualType(src_type));
 
     SetImportInProgress(false);
 
@@ -1933,14 +1935,8 @@
 
     clang::ASTContext *ast = lldb_ast->getASTContext();
 
-    clang::NamedDecl *Decl = VarDecl::Create(*ast,
-                                             const_cast<DeclContext*>(m_decl_context),
-                                             SourceLocation(),
-                                             SourceLocation(),
-                                             ii,
-                                             ClangASTContext::GetQualType(type),
-                                             0,
-                                             SC_Static);
+    clang::NamedDecl *Decl = VarDecl::Create(*ast, const_cast<DeclContext *>(m_decl_context), SourceLocation(),
+                                             SourceLocation(), ii, ClangUtil::GetQualType(type), 0, SC_Static);
     m_decls.push_back(Decl);
 
     return Decl;
@@ -1963,7 +1959,7 @@
 
     m_function_types.insert(type);
 
-    QualType qual_type (ClangASTContext::GetQualType(type));
+    QualType qual_type(ClangUtil::GetQualType(type));
 
     clang::ASTContext *ast = lldb_ast->getASTContext();
 
@@ -2059,7 +2055,7 @@
 {
     if (clang_type)
     {
-        QualType qual_type = ClangASTContext::GetQualType(clang_type);
+        QualType qual_type = ClangUtil::GetQualType(clang_type);
 
         if (const TypedefType *typedef_type = llvm::dyn_cast<TypedefType>(qual_type))
         {
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 8b22d46..62aa5b7 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -25,16 +25,17 @@
 
 #include "clang/AST/ASTContext.h"
 
-#include "lldb/Core/dwarf.h"
 #include "lldb/Core/ConstString.h"
 #include "lldb/Core/DataBufferHeap.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Core/Scalar.h"
 #include "lldb/Core/StreamString.h"
+#include "lldb/Core/dwarf.h"
 #include "lldb/Expression/IRExecutionUnit.h"
 #include "lldb/Expression/IRInterpreter.h"
 #include "lldb/Host/Endian.h"
 #include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ClangUtil.h"
 #include "lldb/Symbol/CompilerType.h"
 
 #include <map>
@@ -1235,11 +1236,8 @@
         if (log)
         {
             log->Printf("Type of \"%s\" is [clang \"%s\", llvm \"%s\"] [size %" PRIu64 ", align %" PRIu64 "]",
-                        name.c_str(),
-                        lldb_private::ClangASTContext::GetQualType(compiler_type).getAsString().c_str(),
-                        PrintType(value_type).c_str(),
-                        value_size,
-                        value_alignment);
+                        name.c_str(), lldb_private::ClangUtil::GetQualType(compiler_type).getAsString().c_str(),
+                        PrintType(value_type).c_str(), value_size, value_alignment);
         }