Eliminate CXXRecordType

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65671 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 6023469..37e4fdb 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -402,8 +402,8 @@
   DeclarationName NewName = Context.DeclarationNames.getCXXOperatorName(
                                         IsArray ? OO_Array_New : OO_New);
   if (AllocType->isRecordType() && !UseGlobal) {
-    CXXRecordDecl *Record = cast<CXXRecordType>(AllocType->getAsRecordType())
-                                ->getDecl();
+    CXXRecordDecl *Record 
+      = cast<CXXRecordDecl>(AllocType->getAsRecordType()->getDecl());
     // FIXME: We fail to find inherited overloads.
     if (FindAllocationOverload(StartLoc, Range, NewName, &AllocArgs[0],
                           AllocArgs.size(), Record, /*AllowMissing=*/true,
diff --git a/lib/Sema/SemaInherit.cpp b/lib/Sema/SemaInherit.cpp
index fe1c96b..a9135a3 100644
--- a/lib/Sema/SemaInherit.cpp
+++ b/lib/Sema/SemaInherit.cpp
@@ -87,7 +87,7 @@
     return false;
 
   Paths.setOrigin(Derived);
-  return LookupInBases(cast<CXXRecordType>(Derived->getAsRecordType())->getDecl(),
+  return LookupInBases(cast<CXXRecordDecl>(Derived->getAsRecordType()->getDecl()),
                        MemberLookupCriteria(Base), Paths);
 }
 
@@ -123,7 +123,7 @@
       if (Paths.isDetectingVirtual() && Paths.DetectedVirtual == 0) {
         // If this is the first virtual we find, remember it. If it turns out
         // there is no base path here, we'll reset it later.
-        Paths.DetectedVirtual = cast<CXXRecordType>(BaseType->getAsRecordType());
+        Paths.DetectedVirtual = BaseType->getAsRecordType();
         SetVirtual = true;
       }
     } else
diff --git a/lib/Sema/SemaInherit.h b/lib/Sema/SemaInherit.h
index 311c136..8d008a2 100644
--- a/lib/Sema/SemaInherit.h
+++ b/lib/Sema/SemaInherit.h
@@ -27,7 +27,6 @@
 
 namespace clang {
   class CXXBaseSpecifier;
-  class CXXRecordType;
 
   /// BasePathElement - An element in a path from a derived class to a
   /// base class. Each step in the path references the link from a
@@ -128,7 +127,7 @@
     BasePath ScratchPath;
 
     /// DetectedVirtual - The base class that is virtual.
-    const CXXRecordType *DetectedVirtual;
+    const RecordType *DetectedVirtual;
 
     friend class Sema;
 
@@ -167,7 +166,7 @@
     bool isDetectingVirtual() const { return DetectVirtual; }
 
     /// getDetectedVirtual - The virtual base discovered on the path.
-    const CXXRecordType* getDetectedVirtual() const {
+    const RecordType* getDetectedVirtual() const {
       return DetectedVirtual;
     }
 
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index c4edbba..5b02221 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -1612,12 +1612,12 @@
     return CheckValueInitialization(AT->getElementType(), Loc);
 
   if (const RecordType *RT = Type->getAsRecordType()) {
-    if (const CXXRecordType *CXXRec = dyn_cast<CXXRecordType>(RT)) {
+    if (CXXRecordDecl *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
       // -- if T is a class type (clause 9) with a user-declared
       //    constructor (12.1), then the default constructor for T is
       //    called (and the initialization is ill-formed if T has no
       //    accessible default constructor);
-      if (CXXRec->getDecl()->hasUserDeclaredConstructor())
+      if (ClassDecl->hasUserDeclaredConstructor())
         // FIXME: Eventually, we'll need to put the constructor decl
         // into the AST.
         return PerformInitializationByConstructor(Type, 0, 0, Loc,
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp
index 00849a6..dd9c850 100644
--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -1232,13 +1232,14 @@
   //        member, if any; and its direct and indirect base
   //        classes. Its associated namespaces are the namespaces in
   //        which its associated classes are defined. 
-  if (const CXXRecordType *ClassType 
-        = dyn_cast_or_null<CXXRecordType>(T->getAsRecordType())) {
-    addAssociatedClassesAndNamespaces(ClassType->getDecl(), 
-                                      Context, AssociatedNamespaces, 
-                                      AssociatedClasses);
-    return;
-  }
+  if (const RecordType *ClassType = T->getAsRecordType())
+    if (CXXRecordDecl *ClassDecl 
+        = dyn_cast<CXXRecordDecl>(ClassType->getDecl())) {
+      addAssociatedClassesAndNamespaces(ClassDecl, Context, 
+                                        AssociatedNamespaces, 
+                                        AssociatedClasses);
+      return;
+    }
 
   //     -- If T is an enumeration type, its associated namespace is
   //        the namespace in which it is defined. If it is class
diff --git a/lib/Sema/SemaNamedCast.cpp b/lib/Sema/SemaNamedCast.cpp
index c5bee98..166ed24 100644
--- a/lib/Sema/SemaNamedCast.cpp
+++ b/lib/Sema/SemaNamedCast.cpp
@@ -706,7 +706,7 @@
     return TSC_Failed;
   }
 
-  if (const CXXRecordType *VBase = Paths.getDetectedVirtual()) {
+  if (const RecordType *VBase = Paths.getDetectedVirtual()) {
     Self.Diag(OpRange.getBegin(), diag::err_memptr_conv_via_virtual)
       << SrcClass << DestClass << QualType(VBase, 0) << OpRange;
     return TSC_Failed;
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index c33389e..fe12eb7 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -1233,7 +1233,7 @@
     return true;
   }
 
-  if (const CXXRecordType *VBase = Paths.getDetectedVirtual()) {
+  if (const RecordType *VBase = Paths.getDetectedVirtual()) {
     Diag(From->getExprLoc(), diag::err_memptr_conv_via_virtual)
       << FromClass << ToClass << QualType(VBase, 0)
       << From->getSourceRange();
@@ -1317,46 +1317,48 @@
                                    bool AllowExplicit)
 {
   OverloadCandidateSet CandidateSet;
-  if (const CXXRecordType *ToRecordType 
-        = dyn_cast_or_null<CXXRecordType>(ToType->getAsRecordType())) {
-    // C++ [over.match.ctor]p1:
-    //   When objects of class type are direct-initialized (8.5), or
-    //   copy-initialized from an expression of the same or a
-    //   derived class type (8.5), overload resolution selects the
-    //   constructor. [...] For copy-initialization, the candidate
-    //   functions are all the converting constructors (12.3.1) of
-    //   that class. The argument list is the expression-list within
-    //   the parentheses of the initializer.
-    CXXRecordDecl *ToRecordDecl = ToRecordType->getDecl();
-    DeclarationName ConstructorName 
-      = Context.DeclarationNames.getCXXConstructorName(
-                        Context.getCanonicalType(ToType).getUnqualifiedType());
-    DeclContext::lookup_iterator Con, ConEnd;
-    for (llvm::tie(Con, ConEnd) = ToRecordDecl->lookup(ConstructorName);
-         Con != ConEnd; ++Con) {
-      CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(*Con);
-      if (Constructor->isConvertingConstructor())
-        AddOverloadCandidate(Constructor, &From, 1, CandidateSet,
-                             /*SuppressUserConversions=*/true);
+  if (const RecordType *ToRecordType = ToType->getAsRecordType()) {
+    if (CXXRecordDecl *ToRecordDecl 
+          = dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
+      // C++ [over.match.ctor]p1:
+      //   When objects of class type are direct-initialized (8.5), or
+      //   copy-initialized from an expression of the same or a
+      //   derived class type (8.5), overload resolution selects the
+      //   constructor. [...] For copy-initialization, the candidate
+      //   functions are all the converting constructors (12.3.1) of
+      //   that class. The argument list is the expression-list within
+      //   the parentheses of the initializer.
+      DeclarationName ConstructorName 
+        = Context.DeclarationNames.getCXXConstructorName(
+                          Context.getCanonicalType(ToType).getUnqualifiedType());
+      DeclContext::lookup_iterator Con, ConEnd;
+      for (llvm::tie(Con, ConEnd) = ToRecordDecl->lookup(ConstructorName);
+           Con != ConEnd; ++Con) {
+        CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(*Con);
+        if (Constructor->isConvertingConstructor())
+          AddOverloadCandidate(Constructor, &From, 1, CandidateSet,
+                               /*SuppressUserConversions=*/true);
+      }
     }
   }
 
   if (!AllowConversionFunctions) {
     // Don't allow any conversion functions to enter the overload set.
-  } else if (const CXXRecordType *FromRecordType
-               = dyn_cast_or_null<CXXRecordType>(
-                                        From->getType()->getAsRecordType())) {
-    // Add all of the conversion functions as candidates.
-    // FIXME: Look for conversions in base classes!
-    CXXRecordDecl *FromRecordDecl = FromRecordType->getDecl();
-    OverloadedFunctionDecl *Conversions 
-      = FromRecordDecl->getConversionFunctions();
-    for (OverloadedFunctionDecl::function_iterator Func 
-           = Conversions->function_begin();
-         Func != Conversions->function_end(); ++Func) {
-      CXXConversionDecl *Conv = cast<CXXConversionDecl>(*Func);
-      if (AllowExplicit || !Conv->isExplicit())
-        AddConversionCandidate(Conv, From, ToType, CandidateSet);
+  } else if (const RecordType *FromRecordType 
+               = From->getType()->getAsRecordType()) {
+    if (CXXRecordDecl *FromRecordDecl 
+          = dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
+      // Add all of the conversion functions as candidates.
+      // FIXME: Look for conversions in base classes!
+      OverloadedFunctionDecl *Conversions 
+        = FromRecordDecl->getConversionFunctions();
+      for (OverloadedFunctionDecl::function_iterator Func 
+             = Conversions->function_begin();
+           Func != Conversions->function_end(); ++Func) {
+        CXXConversionDecl *Conv = cast<CXXConversionDecl>(*Func);
+        if (AllowExplicit || !Conv->isExplicit())
+          AddConversionCandidate(Conv, From, ToType, CandidateSet);
+      }
     }
   }
 
diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index d2e8419..6b43463 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -255,14 +255,6 @@
 }
 
 QualType 
-TemplateTypeInstantiator::InstantiateCXXRecordType(const CXXRecordType *T,
-                                                   unsigned Quals) const {
-  // FIXME: Implement this
-  assert(false && "Cannot instantiate CXXRecordType yet");
-  return QualType();
-}
-
-QualType 
 TemplateTypeInstantiator::InstantiateEnumType(const EnumType *T,
                                               unsigned Quals) const {
   // FIXME: Implement this