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/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index c618ffc..7ed2998 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1591,11 +1591,11 @@
                         llvm::APInt apint (lldb_type->GetByteSize() * 8, uval64, is_signed);
                         template_param_infos.args.push_back (clang::TemplateArgument (*ast,
                                                                                       llvm::APSInt(apint),
-                                                                                      ClangASTContext::GetQualType(clang_type)));
+                                                                                      clang_type.GetQualType()));
                     }
                     else
                     {
-                        template_param_infos.args.push_back (clang::TemplateArgument (ClangASTContext::GetQualType(clang_type)));
+                        template_param_infos.args.push_back (clang::TemplateArgument (clang_type.GetQualType()));
                     }
                 }
                 else
@@ -1722,16 +1722,13 @@
     bool
     Finalize()
     {
-        ClangASTContext* ast = m_class_opaque_type.GetTypeSystem()->AsClangASTContext();
-        assert(ast);
-        return ast->AddObjCClassProperty (m_class_opaque_type,
-                                          m_property_name,
-                                          m_property_opaque_type,
-                                          m_ivar_decl,
-                                          m_property_setter_name,
-                                          m_property_getter_name,
-                                          m_property_attributes,
-                                          m_metadata_ap.get());
+        return m_class_opaque_type.AddObjCClassProperty (m_property_name,
+                                                         m_property_opaque_type,
+                                                         m_ivar_decl,
+                                                         m_property_setter_name,
+                                                         m_property_getter_name,
+                                                         m_property_attributes,
+                                                         m_metadata_ap.get());
     }
 private:
     ClangASTType            m_class_opaque_type;
@@ -1825,9 +1822,6 @@
     uint32_t member_idx = 0;
     BitfieldInfo last_field_info;
     ModuleSP module = GetObjectFile()->GetModule();
-    ClangASTContext* ast = class_clang_type.GetTypeSystem()->AsClangASTContext();
-    if (ast == nullptr)
-        return 0;
 
     for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling())
     {
@@ -2016,8 +2010,7 @@
                         {
                             if (accessibility == eAccessNone)
                                 accessibility = eAccessPublic;
-                            ClangASTContext::AddVariableToRecordType (class_clang_type,
-                                                                      name,
+                            class_clang_type.AddVariableToRecordType (name,
                                                                       var_type->GetClangLayoutType(),
                                                                       accessibility);
                         }
@@ -2134,12 +2127,10 @@
                                         
                                         if (anon_field_info.IsValid())
                                         {
-                                            clang::FieldDecl *unnamed_bitfield_decl =
-                                                ClangASTContext::AddFieldToRecordType (class_clang_type,
-                                                                                       NULL,
-                                                                                       GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize(eEncodingSint, word_width),
-                                                                                       accessibility,
-                                                                                       anon_field_info.bit_size);
+                                            clang::FieldDecl *unnamed_bitfield_decl = class_clang_type.AddFieldToRecordType (NULL,
+                                                                                                                             GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize(eEncodingSint, word_width),
+                                                                                                                             accessibility,
+                                                                                                                             anon_field_info.bit_size);
 
                                             layout_info.field_offsets.insert(
                                                 std::make_pair(unnamed_bitfield_decl, anon_field_info.bit_offset));
@@ -2186,8 +2177,7 @@
                                     }
                                 }
                                 
-                                field_decl = ClangASTContext::AddFieldToRecordType (class_clang_type,
-                                                                                    name,
+                                field_decl = class_clang_type.AddFieldToRecordType (name,
                                                                                     member_clang_type,
                                                                                     accessibility,
                                                                                     bit_size);
@@ -2342,14 +2332,13 @@
                     assert (base_class_clang_type);
                     if (class_language == eLanguageTypeObjC)
                     {
-                        ast->SetObjCSuperClass(class_clang_type, base_class_clang_type);
+                        class_clang_type.SetObjCSuperClass(base_class_clang_type);
                     }
                     else
                     {
-                        base_classes.push_back (ast->CreateBaseClassSpecifier (base_class_clang_type.GetOpaqueQualType(),
-                                                                               accessibility,
-                                                                               is_virtual,
-                                                                               is_base_of_class));
+                        base_classes.push_back (base_class_clang_type.CreateBaseClassSpecifier (accessibility,
+                                                                                               is_virtual, 
+                                                                                               is_base_of_class));
                         
                         if (is_virtual)
                         {
@@ -2364,7 +2353,7 @@
                         else
                         {
                             layout_info.base_offsets.insert(
-                                std::make_pair(ast->GetAsCXXRecordDecl(base_class_clang_type.GetOpaqueQualType()),
+                                std::make_pair(base_class_clang_type.GetAsCXXRecordDecl(),
                                                clang::CharUnits::fromQuantity(member_byte_offset)));
                         }
                     }
@@ -2485,7 +2474,7 @@
 bool
 SymbolFileDWARF::HasForwardDeclForClangType (const ClangASTType &clang_type)
 {
-    ClangASTType clang_type_no_qualifiers = ClangASTContext::RemoveFastQualifiers(clang_type);
+    ClangASTType clang_type_no_qualifiers = clang_type.RemoveFastQualifiers();
     const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (clang_type_no_qualifiers.GetOpaqueQualType());
     return die != NULL;
 }
@@ -2495,7 +2484,7 @@
 SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (ClangASTType &clang_type)
 {
     // We have a struct/union/class/enum that needs to be fully resolved.
-    ClangASTType clang_type_no_qualifiers = ClangASTContext::RemoveFastQualifiers(clang_type);
+    ClangASTType clang_type_no_qualifiers = clang_type.RemoveFastQualifiers();
     const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (clang_type_no_qualifiers.GetOpaqueQualType());
     if (die == NULL)
     {
@@ -2508,16 +2497,9 @@
     // are done.
     m_forward_decl_clang_type_to_die.erase (clang_type_no_qualifiers.GetOpaqueQualType());
 
-    ClangASTContext* ast = clang_type.GetTypeSystem()->AsClangASTContext();
-    if (ast == NULL)
-    {
-        // Not a clang type
-        return true;
-    }
-    
     // Disable external storage for this type so we don't get anymore 
     // clang::ExternalASTSource queries for this type.
-    ast->SetHasExternalStorage (clang_type.GetOpaqueQualType(), false);
+    clang_type.SetHasExternalStorage (false);
 
     DWARFDebugInfo* debug_info = DebugInfo();
 
@@ -2548,12 +2530,12 @@
                 if (die->HasChildren())
                 {
                     LanguageType class_language = eLanguageTypeUnknown;
-                    if (ClangASTContext::IsObjCObjectOrInterfaceType(clang_type))
+                    if (clang_type.IsObjCObjectOrInterfaceType())
                     {
                         class_language = eLanguageTypeObjC;
                         // For objective C we don't start the definition when
                         // the class is created.
-                        ClangASTContext::StartTagDeclarationDefinition (clang_type);
+                        clang_type.StartTagDeclarationDefinition ();
                     }
 
                     int tag_decl_kind = -1;
@@ -2660,7 +2642,7 @@
                     if (class_language != eLanguageTypeObjC)
                     {
                         if (is_a_class && tag_decl_kind != clang::TTK_Class)
-                            GetClangASTContext().SetTagTypeKind (ClangASTContext::GetQualType(clang_type), clang::TTK_Class);
+                            clang_type.SetTagTypeKind (clang::TTK_Class);
                     }
 
                     // Since DW_TAG_structure_type gets used for both classes
@@ -2677,10 +2659,9 @@
                     {
                         // This is a class and all members that didn't have
                         // their access specified are private.
-                        GetClangASTContext().SetDefaultAccessForRecordFields (ast->GetAsRecordDecl(clang_type),
-                                                                              eAccessPrivate,
-                                                                              &member_accessibilities.front(),
-                                                                              member_accessibilities.size());
+                        clang_type.SetDefaultAccessForRecordFields (eAccessPrivate,
+                                                                    &member_accessibilities.front(),
+                                                                    member_accessibilities.size());
                     }
 
                     if (!base_classes.empty())
@@ -2711,26 +2692,24 @@
                                     // below. Since we provide layout assistance, all ivars in this
                                     // class and other classes will be fine, this is the best we can do
                                     // short of crashing.
-                                    
-                                    ClangASTContext::StartTagDeclarationDefinition (base_class_type);
-                                    ClangASTContext::CompleteTagDeclarationDefinition (base_class_type);
+                                    base_class_type.StartTagDeclarationDefinition ();
+                                    base_class_type.CompleteTagDeclarationDefinition ();
                                 }
                             }
                         }
-                        ast->SetBaseClassesForClassType (clang_type.GetOpaqueQualType(),
-                                                           &base_classes.front(),
-                                                           base_classes.size());
+                        clang_type.SetBaseClassesForClassType (&base_classes.front(),
+                                                               base_classes.size());
 
                         // Clang will copy each CXXBaseSpecifier in "base_classes"
                         // so we have to free them all.
-                        ClangASTContext::DeleteBaseClassSpecifiers (&base_classes.front(),
-                                                                    base_classes.size());
+                        ClangASTType::DeleteBaseClassSpecifiers (&base_classes.front(),
+                                                                 base_classes.size());
                     }
                 }
             }
 
-            ClangASTContext::BuildIndirectFields (clang_type);
-            ClangASTContext::CompleteTagDeclarationDefinition (clang_type);
+            clang_type.BuildIndirectFields ();
+            clang_type.CompleteTagDeclarationDefinition ();
 
             if (!layout_info.field_offsets.empty() ||
                 !layout_info.base_offsets.empty()  ||
@@ -2741,7 +2720,7 @@
                 if (layout_info.bit_size == 0)
                     layout_info.bit_size = die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_byte_size, 0) * 8;
 
-                clang::CXXRecordDecl *record_decl = ast->GetAsCXXRecordDecl(clang_type.GetOpaqueQualType());
+                clang::CXXRecordDecl *record_decl = clang_type.GetAsCXXRecordDecl();
                 if (record_decl)
                 {
                     if (log)
@@ -2806,7 +2785,7 @@
         return (bool)clang_type;
 
     case DW_TAG_enumeration_type:
-        ClangASTContext::StartTagDeclarationDefinition (clang_type);
+        clang_type.StartTagDeclarationDefinition ();
         if (die->HasChildren())
         {
             SymbolContext sc(GetCompUnitForDWARFCompUnit(dwarf_cu));
@@ -2814,7 +2793,7 @@
             clang_type.IsIntegerType(is_signed);
             ParseChildEnumerators(sc, clang_type, is_signed, type->GetByteSize(), dwarf_cu, die);
         }
-        ClangASTContext::CompleteTagDeclarationDefinition (clang_type);
+        clang_type.CompleteTagDeclarationDefinition ();
         return (bool)clang_type;
 
     default:
@@ -4685,17 +4664,12 @@
 
                 if (name && name[0] && got_value)
                 {
-                    ClangASTContext* ast = clang_type.GetTypeSystem()->AsClangASTContext();
-                    if (ast)
-                    {
-                        ast->AddEnumerationValueToEnumerationType (clang_type.GetOpaqueQualType(),
-                                                                   ast->GetEnumerationIntegerType(clang_type.GetOpaqueQualType()),
-                                                                   decl,
-                                                                   name,
-                                                                   enum_value,
-                                                                   enumerator_byte_size * 8);
-                        ++enumerators_added;
-                    }
+                    clang_type.AddEnumerationValueToEnumerationType (clang_type.GetEnumerationIntegerType(),
+                                                                     decl,
+                                                                     name,
+                                                                     enum_value,
+                                                                     enumerator_byte_size * 8);
+                    ++enumerators_added;
                 }
             }
         }
@@ -4962,7 +4936,7 @@
                 Type* type = ResolveType (cu, decl_ctx_die);
                 if (type)
                 {
-                    clang::DeclContext *decl_ctx = GetClangASTContext().GetDeclContextForType(type->GetClangForwardType());
+                    clang::DeclContext *decl_ctx = type->GetClangForwardType().GetDeclContextForType ();
                     if (decl_ctx)
                     {
                         LinkDeclContextToDIE (decl_ctx, decl_ctx_die);
@@ -6264,7 +6238,7 @@
                     }
                     assert (tag_decl_kind != -1);
                     bool clang_type_was_created = false;
-                    clang_type.SetClangType(&ast, m_forward_decl_die_to_clang_type.lookup (die));
+                    clang_type.SetClangType(ast.getASTContext(), m_forward_decl_die_to_clang_type.lookup (die));
                     if (!clang_type)
                     {
                         const DWARFDebugInfoEntry *decl_ctx_die;
@@ -6321,7 +6295,7 @@
                     // Store a forward declaration to this class type in case any 
                     // parameters in any class methods need it for the clang 
                     // types for function prototypes.
-                    LinkDeclContextToDIE(ast.GetDeclContextForType(clang_type), die);
+                    LinkDeclContextToDIE(clang_type.GetDeclContextForType(), die);
                     type_sp.reset (new Type (MakeUserID(die->GetOffset()), 
                                              this, 
                                              type_name_const_str, 
@@ -6386,12 +6360,12 @@
                         if (die->HasChildren() == false)
                         {
                             // No children for this struct/union/class, lets finish it
-                            ClangASTContext::StartTagDeclarationDefinition (clang_type);
-                            ClangASTContext::CompleteTagDeclarationDefinition (clang_type);
+                            clang_type.StartTagDeclarationDefinition ();
+                            clang_type.CompleteTagDeclarationDefinition ();
 
                             if (tag == DW_TAG_structure_type) // this only applies in C
                             {
-                                clang::RecordDecl *record_decl = ClangASTContext::GetAsRecordDecl(clang_type);
+                                clang::RecordDecl *record_decl = clang_type.GetAsRecordDecl();
 
                                 if (record_decl)
                                     m_record_decl_to_layout_map.insert(std::make_pair(record_decl, LayoutInfo()));
@@ -6409,7 +6383,7 @@
 
                             if (class_language != eLanguageTypeObjC &&
                                 class_language != eLanguageTypeObjC_plus_plus)
-                                ClangASTContext::StartTagDeclarationDefinition (clang_type);
+                                clang_type.StartTagDeclarationDefinition ();
 
                             // Leave this as a forward declaration until we need
                             // to know the details of the type. lldb_private::Type
@@ -6417,8 +6391,8 @@
                             // "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition(Type *)"
                             // When the definition needs to be defined.
                             m_forward_decl_die_to_clang_type[die] = clang_type.GetOpaqueQualType();
-                            m_forward_decl_clang_type_to_die[ClangASTContext::RemoveFastQualifiers(clang_type).GetOpaqueQualType()] = die;
-                            ast.SetHasExternalStorage (clang_type.GetOpaqueQualType(), true);
+                            m_forward_decl_clang_type_to_die[clang_type.RemoveFastQualifiers().GetOpaqueQualType()] = die;
+                            clang_type.SetHasExternalStorage (true);
                         }
                     }
 
@@ -6474,7 +6448,7 @@
                         DEBUG_PRINTF ("0x%8.8" PRIx64 ": %s (\"%s\")\n", MakeUserID(die->GetOffset()), DW_TAG_value_to_name(tag), type_name_cstr);
 
                         ClangASTType enumerator_clang_type;
-                        clang_type.SetClangType (&ast, m_forward_decl_die_to_clang_type.lookup (die));
+                        clang_type.SetClangType (ast.getASTContext(), m_forward_decl_die_to_clang_type.lookup (die));
                         if (!clang_type)
                         {
                             if (encoding_uid != DW_INVALID_OFFSET)
@@ -6496,10 +6470,10 @@
                         }
                         else
                         {
-                            enumerator_clang_type = ast.GetEnumerationIntegerType (clang_type.GetOpaqueQualType());
+                            enumerator_clang_type = clang_type.GetEnumerationIntegerType ();
                         }
 
-                        LinkDeclContextToDIE(ClangASTContext::GetDeclContextForType(clang_type), die);
+                        LinkDeclContextToDIE(clang_type.GetDeclContextForType(), die);
 
                         type_sp.reset( new Type (MakeUserID(die->GetOffset()), 
                                                  this, 
@@ -6512,7 +6486,7 @@
                                                  clang_type, 
                                                  Type::eResolveStateForward));
 
-                        ClangASTContext::StartTagDeclarationDefinition (clang_type);
+                        clang_type.StartTagDeclarationDefinition ();
                         if (die->HasChildren())
                         {
                             SymbolContext cu_sc(GetCompUnitForDWARFCompUnit(dwarf_cu));
@@ -6520,7 +6494,7 @@
                             enumerator_clang_type.IsIntegerType(is_signed);
                             ParseChildEnumerators(cu_sc, clang_type, is_signed, type_sp->GetByteSize(), dwarf_cu, die);
                         }
-                        ClangASTContext::CompleteTagDeclarationDefinition (clang_type);
+                        clang_type.CompleteTagDeclarationDefinition ();
                     }
                 }
                 break;
@@ -6710,7 +6684,7 @@
                                     if (complete_objc_class_type_sp)
                                     {
                                         ClangASTType type_clang_forward_type = complete_objc_class_type_sp->GetClangForwardType();
-                                        if (ClangASTContext::IsObjCObjectOrInterfaceType(type_clang_forward_type))
+                                        if (type_clang_forward_type.IsObjCObjectOrInterfaceType ())
                                             class_opaque_type = type_clang_forward_type;
                                     }
                                 }
@@ -6722,11 +6696,10 @@
                                     if (accessibility == eAccessNone)
                                         accessibility = eAccessPublic;
 
-                                    clang::ObjCMethodDecl *objc_method_decl = ast.AddMethodToObjCObjectType (class_opaque_type,
-                                                                                                             type_name_cstr,
-                                                                                                             clang_type,
-                                                                                                             accessibility,
-                                                                                                             is_artificial);
+                                    clang::ObjCMethodDecl *objc_method_decl = class_opaque_type.AddMethodToObjCObjectType (type_name_cstr,
+                                                                                                                           clang_type,
+                                                                                                                           accessibility,
+                                                                                                                           is_artificial);
                                     type_handled = objc_method_decl != NULL;
                                     if (type_handled)
                                     {
@@ -6846,7 +6819,7 @@
                                     else
                                     {
                                         ClangASTType class_opaque_type = class_type->GetClangForwardType();
-                                        if (ClangASTContext::IsCXXClassType(class_opaque_type))
+                                        if (class_opaque_type.IsCXXClassType ())
                                         {
                                             if (class_opaque_type.IsBeingDefined ())
                                             {
@@ -6874,16 +6847,15 @@
 
                                                     const bool is_attr_used = false;
 
-                                                    cxx_method_decl = ast.AddMethodToCXXRecordType (class_opaque_type.GetOpaqueQualType(),
-                                                                                                    type_name_cstr,
-                                                                                                    clang_type,
-                                                                                                    accessibility,
-                                                                                                    is_virtual,
-                                                                                                    is_static,
-                                                                                                    is_inline,
-                                                                                                    is_explicit,
-                                                                                                    is_attr_used,
-                                                                                                    is_artificial);
+                                                    cxx_method_decl = class_opaque_type.AddMethodToCXXRecordType (type_name_cstr,
+                                                                                                                  clang_type,
+                                                                                                                  accessibility,
+                                                                                                                  is_virtual,
+                                                                                                                  is_static,
+                                                                                                                  is_inline,
+                                                                                                                  is_explicit,
+                                                                                                                  is_attr_used,
+                                                                                                                  is_artificial);
 
                                                     type_handled = cxx_method_decl != NULL;
 
@@ -7136,7 +7108,7 @@
                         ClangASTType pointee_clang_type = pointee_type->GetClangForwardType();
                         ClangASTType class_clang_type = class_type->GetClangLayoutType();
 
-                        clang_type = ClangASTContext::CreateMemberPointerType(pointee_clang_type, class_clang_type);
+                        clang_type = pointee_clang_type.CreateMemberPointerType(class_clang_type);
 
                         byte_size = clang_type.GetByteSize(nullptr);
 
@@ -8053,7 +8025,7 @@
                 
                 Type *matching_type = ResolveType (dwarf_cu, die);
                 
-                clang::QualType qual_type = ClangASTContext::GetQualType(matching_type->GetClangForwardType());
+                clang::QualType qual_type = matching_type->GetClangForwardType().GetQualType();
                 
                 if (const clang::TagType *tag_type = llvm::dyn_cast<clang::TagType>(qual_type.getTypePtr()))
                 {