Revert "Introduce a TypeSystem interface to support adding non-clang languages."

This seems to break expression evaluation on the linux build.

llvm-svn: 239366
diff --git a/lldb/source/Expression/ASTDumper.cpp b/lldb/source/Expression/ASTDumper.cpp
index 80faeb3..5210d14 100644
--- a/lldb/source/Expression/ASTDumper.cpp
+++ b/lldb/source/Expression/ASTDumper.cpp
@@ -9,7 +9,6 @@
 
 #include "lldb/Core/Log.h"
 #include "lldb/Expression/ASTDumper.h"
-#include "lldb/Symbol/ClangASTContext.h"
 #include "lldb/Symbol/ClangASTType.h"
 
 #include "llvm/Support/raw_ostream.h"
@@ -82,7 +81,7 @@
 
 ASTDumper::ASTDumper (const ClangASTType &clang_type)
 {
-    m_dump = ClangASTContext::GetQualType(clang_type).getAsString();
+    m_dump = clang_type.GetQualType().getAsString();
 }
 
 
diff --git a/lldb/source/Expression/ClangASTSource.cpp b/lldb/source/Expression/ClangASTSource.cpp
index b6ea7a8..3988cd6 100644
--- a/lldb/source/Expression/ClangASTSource.cpp
+++ b/lldb/source/Expression/ClangASTSource.cpp
@@ -277,7 +277,7 @@
                     if (!clang_type)
                         continue;
 
-                    const TagType *tag_type = ClangASTContext::GetQualType(clang_type)->getAs<TagType>();
+                    const TagType *tag_type = clang_type.GetQualType()->getAs<TagType>();
 
                     if (!tag_type)
                         continue;
@@ -316,7 +316,7 @@
                 if (!clang_type)
                     continue;
 
-                const TagType *tag_type = ClangASTContext::GetQualType(clang_type)->getAs<TagType>();
+                const TagType *tag_type = clang_type.GetQualType()->getAs<TagType>();
 
                 if (!tag_type)
                     continue;
@@ -1886,13 +1886,9 @@
 {
     ClangASTMetrics::RegisterLLDBImport();
 
-    ClangASTContext* src_ast = src_type.GetTypeSystem()->AsClangASTContext();
-    if (!src_ast)
-        return ClangASTType();
-    
     SetImportInProgress(true);
 
-    QualType copied_qual_type = m_ast_importer->CopyType (m_ast_context, src_ast->getASTContext(), ClangASTContext::GetQualType(src_type));
+    QualType copied_qual_type = m_ast_importer->CopyType (m_ast_context, src_type.GetASTContext(), src_type.GetQualType());
 
     SetImportInProgress(false);
 
@@ -1912,20 +1908,16 @@
     if (!type.IsValid())
         return NULL;
 
-    ClangASTContext* lldb_ast = type.GetTypeSystem()->AsClangASTContext();
-    if (!lldb_ast)
-        return NULL;
-    
     IdentifierInfo *ii = m_decl_name.getAsIdentifierInfo();
 
-    clang::ASTContext *ast = lldb_ast->getASTContext();
+    clang::ASTContext *ast = type.GetASTContext();
 
     clang::NamedDecl *Decl = VarDecl::Create(*ast,
                                              const_cast<DeclContext*>(m_decl_context),
                                              SourceLocation(),
                                              SourceLocation(),
                                              ii,
-                                             ClangASTContext::GetQualType(type),
+                                             type.GetQualType(),
                                              0,
                                              SC_Static);
     m_decls.push_back(Decl);
@@ -1943,16 +1935,12 @@
 
     if (m_function_types.count(type))
         return NULL;
-    
-    ClangASTContext* lldb_ast = type.GetTypeSystem()->AsClangASTContext();
-    if (!lldb_ast)
-        return NULL;
 
     m_function_types.insert(type);
 
-    QualType qual_type (ClangASTContext::GetQualType(type));
+    QualType qual_type (type.GetQualType());
 
-    clang::ASTContext *ast = lldb_ast->getASTContext();
+    clang::ASTContext *ast = type.GetASTContext();
 
     const bool isInlineSpecified = false;
     const bool hasWrittenPrototype = true;
@@ -2043,7 +2031,7 @@
 {
     if (clang_type)
     {
-        QualType qual_type = ClangASTContext::GetQualType(clang_type);
+        QualType qual_type = clang_type.GetQualType();
 
         if (const TypedefType *typedef_type = llvm::dyn_cast<TypedefType>(qual_type))
         {
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index d00e455..7574723 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -201,10 +201,10 @@
         if (target == NULL)
             return false;
 
-        ClangASTContext *context(target->GetScratchClangASTContext());
+        ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
 
-        TypeFromUser user_type(m_ast_importer->DeportType(context->getASTContext(),
-                                                          parser_type.GetTypeSystem()->AsClangASTContext()->getASTContext(),
+        TypeFromUser user_type(m_ast_importer->DeportType(context,
+                                                          parser_type.GetASTContext(),
                                                           parser_type.GetOpaqueQualType()),
                                context);
 
@@ -241,10 +241,10 @@
     if (target == NULL)
         return false;
 
-    ClangASTContext *context(target->GetScratchClangASTContext());
+    ASTContext *context(target->GetScratchClangASTContext()->getASTContext());
 
-    TypeFromUser user_type(m_ast_importer->DeportType(context->getASTContext(),
-                                                      parser_type.GetTypeSystem()->AsClangASTContext()->getASTContext(),
+    TypeFromUser user_type(m_ast_importer->DeportType(context,
+                                                      parser_type.GetASTContext(),
                                                       parser_type.GetOpaqueQualType()),
                            context);
 
@@ -1041,7 +1041,7 @@
                 QualType class_qual_type(class_decl->getTypeForDecl(), 0);
 
                 TypeFromUser class_user_type (class_qual_type.getAsOpaquePtr(),
-                                              ClangASTContext::GetASTContext(&class_decl->getASTContext()));
+                                              &class_decl->getASTContext());
 
                 if (log)
                 {
@@ -1079,7 +1079,7 @@
                     QualType class_pointer_type = method_decl->getASTContext().getPointerType(class_qual_type);
 
                     TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
-                                                ClangASTContext::GetASTContext(&method_decl->getASTContext()));
+                                                &method_decl->getASTContext());
 
                     m_struct_vars->m_object_pointer_type = self_user_type;
                 }
@@ -1169,7 +1169,7 @@
                     return; // This is unlikely, but we have seen crashes where this occurred
 
                 TypeFromUser class_user_type(QualType(interface_type, 0).getAsOpaquePtr(),
-                                             ClangASTContext::GetASTContext(&method_decl->getASTContext()));
+                                             &method_decl->getASTContext());
 
                 if (log)
                 {
@@ -1186,7 +1186,7 @@
                     QualType class_pointer_type = method_decl->getASTContext().getObjCObjectPointerType(QualType(interface_type, 0));
 
                     TypeFromUser self_user_type(class_pointer_type.getAsOpaquePtr(),
-                                                ClangASTContext::GetASTContext(&method_decl->getASTContext()));
+                                                &method_decl->getASTContext());
 
                     m_struct_vars->m_object_pointer_type = self_user_type;
                 }
@@ -1196,7 +1196,7 @@
                     QualType class_type = method_decl->getASTContext().getObjCClassType();
 
                     TypeFromUser self_user_type(class_type.getAsOpaquePtr(),
-                                                ClangASTContext::GetASTContext(&method_decl->getASTContext()));
+                                                &method_decl->getASTContext());
 
                     m_struct_vars->m_object_pointer_type = self_user_type;
                 }
@@ -1225,11 +1225,11 @@
 
                     ClangASTType self_clang_type = self_type->GetClangFullType();
 
-                    if (ClangASTContext::IsObjCClassType(self_clang_type))
+                    if (self_clang_type.IsObjCClassType())
                     {
                         return;
                     }
-                    else if (ClangASTContext::IsObjCObjectPointerType(self_clang_type))
+                    else if (self_clang_type.IsObjCObjectPointerType())
                     {
                         self_clang_type = self_clang_type.GetPointeeType();
 
@@ -1726,7 +1726,7 @@
     if (is_reference)
         var_decl = context.AddVarDecl(pt);
     else
-        var_decl = context.AddVarDecl(ClangASTContext::GetLValueReferenceType(pt));
+        var_decl = context.AddVarDecl(pt.GetLValueReferenceType());
 
     std::string decl_name(context.m_decl_name.getAsString());
     ConstString entity_name(decl_name.c_str());
@@ -1770,7 +1770,7 @@
         return;
     }
 
-    NamedDecl *var_decl = context.AddVarDecl(ClangASTContext::GetLValueReferenceType(parser_type));
+    NamedDecl *var_decl = context.AddVarDecl(parser_type.GetLValueReferenceType());
 
     pvar_sp->EnableParserVars(GetParserID());
     ClangExpressionVariable::ParserVars *parser_vars = pvar_sp->GetParserVars(GetParserID());
@@ -1802,8 +1802,8 @@
 
     ASTContext *scratch_ast_context = target->GetScratchClangASTContext()->getASTContext();
 
-    TypeFromUser user_type (ClangASTContext::GetLValueReferenceType(ClangASTContext::GetBasicType(scratch_ast_context, eBasicTypeVoid).GetPointerType()));
-    TypeFromParser parser_type (ClangASTContext::GetLValueReferenceType(ClangASTContext::GetBasicType(m_ast_context, eBasicTypeVoid).GetPointerType()));
+    TypeFromUser user_type (ClangASTContext::GetBasicType(scratch_ast_context, eBasicTypeVoid).GetPointerType().GetLValueReferenceType());
+    TypeFromParser parser_type (ClangASTContext::GetBasicType(m_ast_context, eBasicTypeVoid).GetPointerType().GetLValueReferenceType());
     NamedDecl *var_decl = context.AddVarDecl(parser_type);
 
     std::string decl_name(context.m_decl_name.getAsString());
@@ -1845,7 +1845,7 @@
     Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
     Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
 
-    ClangASTContext *scratch_ast_context = target->GetScratchClangASTContext();
+    ASTContext *scratch_ast_context = target->GetScratchClangASTContext()->getASTContext();
 
     for (size_t index = 0, num_entities = m_found_entities.GetSize();
          index < num_entities;
@@ -1874,9 +1874,9 @@
             }
 
             QualType var_type = var_decl->getType();
-            TypeFromParser parser_type(var_type.getAsOpaquePtr(), ClangASTContext::GetASTContext(&var_decl->getASTContext()));
+            TypeFromParser parser_type(var_type.getAsOpaquePtr(), &var_decl->getASTContext());
 
-            lldb::clang_type_t copied_type = m_ast_importer->CopyType(scratch_ast_context->getASTContext(), &var_decl->getASTContext(), var_type.getAsOpaquePtr());
+            lldb::clang_type_t copied_type = m_ast_importer->CopyType(scratch_ast_context, &var_decl->getASTContext(), var_type.getAsOpaquePtr());
 
             if (!copied_type)
             {
@@ -2114,17 +2114,15 @@
         const bool is_attr_used = true;
         const bool is_artificial = false;
 
-        ClangASTContext::GetASTContext(m_ast_context)->
-            AddMethodToCXXRecordType (copied_clang_type.GetOpaqueQualType(),
-                                      "$__lldb_expr",
-                                      method_type,
-                                      lldb::eAccessPublic,
-                                      is_virtual,
-                                      is_static,
-                                      is_inline,
-                                      is_explicit,
-                                      is_attr_used,
-                                      is_artificial);
+        copied_clang_type.AddMethodToCXXRecordType ("$__lldb_expr",
+                                                    method_type,
+                                                    lldb::eAccessPublic,
+                                                    is_virtual,
+                                                    is_static,
+                                                    is_inline,
+                                                    is_explicit,
+                                                    is_attr_used,
+                                                    is_artificial);
     }
 
     return TypeFromParser(copied_clang_type);
diff --git a/lldb/source/Expression/ClangUserExpression.cpp b/lldb/source/Expression/ClangUserExpression.cpp
index ebdc45c..38e6ddb 100644
--- a/lldb/source/Expression/ClangUserExpression.cpp
+++ b/lldb/source/Expression/ClangUserExpression.cpp
@@ -313,11 +313,11 @@
                         return;
                     }
 
-                    if (ClangASTContext::IsObjCClassType(self_clang_type))
+                    if (self_clang_type.IsObjCClassType())
                     {
                         return;
                     }
-                    else if (ClangASTContext::IsObjCObjectPointerType(self_clang_type))
+                    else if (self_clang_type.IsObjCObjectPointerType())
                     {
                         m_objectivec = true;
                         m_needs_object_ptr = true;
diff --git a/lldb/source/Expression/IRForTarget.cpp b/lldb/source/Expression/IRForTarget.cpp
index eb4c919..e1059c3 100644
--- a/lldb/source/Expression/IRForTarget.cpp
+++ b/lldb/source/Expression/IRForTarget.cpp
@@ -575,14 +575,14 @@
             clang::QualType element_qual_type = pointer_pointertype->getPointeeType();
 
             m_result_type = lldb_private::TypeFromParser(element_qual_type.getAsOpaquePtr(),
-                                                         lldb_private::ClangASTContext::GetASTContext(&result_decl->getASTContext()));
+                                                         &result_decl->getASTContext());
         }
         else if (pointer_objcobjpointertype)
         {
             clang::QualType element_qual_type = clang::QualType(pointer_objcobjpointertype->getObjectType(), 0);
 
             m_result_type = lldb_private::TypeFromParser(element_qual_type.getAsOpaquePtr(),
-                                                         lldb_private::ClangASTContext::GetASTContext(&result_decl->getASTContext()));
+                                                         &result_decl->getASTContext());
         }
         else
         {
@@ -598,7 +598,7 @@
     else
     {
         m_result_type = lldb_private::TypeFromParser(result_var->getType().getAsOpaquePtr(),
-                                                     lldb_private::ClangASTContext::GetASTContext(&result_decl->getASTContext()));
+                                                     &result_decl->getASTContext());
     }
 
 
@@ -1241,7 +1241,7 @@
     clang::VarDecl *decl = reinterpret_cast<clang::VarDecl *>(ptr);
 
     lldb_private::TypeFromParser result_decl_type (decl->getType().getAsOpaquePtr(),
-                                                   lldb_private::ClangASTContext::GetASTContext(&decl->getASTContext()));
+                                                   &decl->getASTContext());
 
     StringRef decl_name (decl->getName());
     lldb_private::ConstString persistent_variable_name (decl_name.data(), decl_name.size());
@@ -1539,7 +1539,7 @@
         {
             log->Printf("Type of \"%s\" is [clang \"%s\", llvm \"%s\"] [size %" PRIu64 ", align %" PRIu64 "]",
                         name.c_str(),
-                        lldb_private::ClangASTContext::GetQualType(clang_type).getAsString().c_str(),
+                        clang_type.GetQualType().getAsString().c_str(),
                         PrintType(value_type).c_str(),
                         value_size,
                         value_alignment);