Huge change to clean up types.

A long time ago we start with clang types that were created by the symbol files and there were many functions in lldb_private::ClangASTContext that helped. Later we create ClangASTType which contains a clang::ASTContext and an opauque QualType, but we didn't switch over to fully using it. There were a lot of places where we would pass around a raw clang_type_t and also pass along a clang::ASTContext separately. This left room for error.

This checkin change all type code over to use ClangASTType everywhere and I cleaned up the interfaces quite a bit. Any code that was in ClangASTContext that was type related, was moved over into ClangASTType. All code that used these types was switched over to use all of the new goodness.

llvm-svn: 186130
diff --git a/lldb/source/Expression/IRForTarget.cpp b/lldb/source/Expression/IRForTarget.cpp
index 37b4240..7119434 100644
--- a/lldb/source/Expression/IRForTarget.cpp
+++ b/lldb/source/Expression/IRForTarget.cpp
@@ -33,6 +33,7 @@
 #include "lldb/Expression/IRInterpreter.h"
 #include "lldb/Host/Endian.h"
 #include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ClangASTType.h"
 
 #include <map>
 
@@ -130,7 +131,7 @@
 }
 
 static std::string
-PrintType(const Type *type, bool truncate = false)
+PrintType(const llvm::Type *type, bool truncate = false)
 {
     std::string s;
     raw_string_ostream rso(s);
@@ -565,7 +566,7 @@
                                                      &result_decl->getASTContext());
     }
     
-    if (m_result_type.GetClangTypeBitWidth() == 0)
+    if (m_result_type.GetBitSize() == 0)
     {
         lldb_private::StreamString type_desc_stream;
         m_result_type.DumpTypeDescription(&type_desc_stream);
@@ -592,7 +593,7 @@
     if (log)
         log->Printf("Creating a new result global: \"%s\" with size 0x%" PRIx64,
                     m_result_name.GetCString(),
-                    m_result_type.GetClangTypeBitWidth() / 8);
+                    m_result_type.GetByteSize());
         
     // Construct a new result global and set up its metadata
     
@@ -1496,22 +1497,14 @@
         
         std::string name (named_decl->getName().str());
         
-        void *opaque_type = NULL;
-        clang::ASTContext *ast_context = NULL;
-        
-        if (clang::ValueDecl *value_decl = dyn_cast<clang::ValueDecl>(named_decl))
-        {
-            opaque_type = value_decl->getType().getAsOpaquePtr();
-            ast_context = &value_decl->getASTContext();
-        }
-        else
-        {
+        clang::ValueDecl *value_decl = dyn_cast<clang::ValueDecl>(named_decl);
+        if (value_decl == NULL)
             return false;
-        }
+
+        lldb_private::ClangASTType clang_type(&value_decl->getASTContext(), value_decl->getType());
         
-        clang::QualType qual_type;
         const Type *value_type = NULL;
-        
+
         if (name[0] == '$')
         {
             // The $__lldb_expr_result name indicates the the return value has allocated as
@@ -1523,26 +1516,26 @@
             // to the type of $__lldb_expr_result, not the type itself.
             //
             // We also do this for any user-declared persistent variables.
-            
-            qual_type = ast_context->getPointerType(clang::QualType::getFromOpaquePtr(opaque_type));
+            clang_type = clang_type.GetPointerType();
             value_type = PointerType::get(global_variable->getType(), 0);
         }
         else
         {
-            qual_type = clang::QualType::getFromOpaquePtr(opaque_type);
             value_type = global_variable->getType();
         }
-                
-        uint64_t value_size = (ast_context->getTypeSize(qual_type) + 7ull) / 8ull;
-        off_t value_alignment = (ast_context->getTypeAlign(qual_type) + 7ull) / 8ull;
+        
+        const uint64_t value_size = clang_type.GetByteSize();
+        off_t value_alignment = (clang_type.GetTypeBitAlign() + 7ull) / 8ull;
         
         if (log)
+        {
             log->Printf("Type of \"%s\" is [clang \"%s\", llvm \"%s\"] [size %" PRIu64 ", align %" PRId64 "]",
                         name.c_str(), 
-                        qual_type.getAsString().c_str(), 
-                        PrintType(value_type).c_str(), 
+                        clang_type.GetQualType().getAsString().c_str(),
+                        PrintType(value_type).c_str(),
                         value_size, 
                         value_alignment);
+        }
         
         
         if (named_decl && !m_decl_map->AddValueToStruct(named_decl,