Make Sema::getTypeName return the opaque pointer of a QualType rather
than a Decl, which gives us some more flexibility to express the
results with the type system. There are no clients using this
flexibility yet, but it's meant to be able to describe qualified names
as written in the source (e.g., "foo::type") or template-ids that name
a class template specialization (e.g., "std::vector<INT>").

DeclSpec's TST_typedef has become TST_typename, to reflect its use to
describe types found by name (that may or may not be typedefs). The
type representation of a DeclSpec with TST_typename is an opaque
QualType pointer. All users of TST_typedef, both direct and indirect,
have been updated for these changes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64141 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index c4c526e..02c2e9b 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -318,7 +318,7 @@
                          bool Virtual, AccessSpecifier Access,
                          TypeTy *basetype, SourceLocation BaseLoc) {
   CXXRecordDecl *Decl = (CXXRecordDecl*)classdecl;
-  QualType BaseType = Context.getTypeDeclType((TypeDecl*)basetype);
+  QualType BaseType = QualType::getFromOpaquePtr(basetype);
 
   // Base specifiers must be record types.
   if (!BaseType->isRecordType())
@@ -481,15 +481,15 @@
   }
 
   if (!isFunc &&
-      D.getDeclSpec().getTypeSpecType() == DeclSpec::TST_typedef &&
+      D.getDeclSpec().getTypeSpecType() == DeclSpec::TST_typename &&
       D.getNumTypeObjects() == 0) {
     // Check also for this case:
     //
     // typedef int f();
     // f a;
     //
-    Decl *TD = static_cast<Decl *>(DS.getTypeRep());
-    isFunc = Context.getTypeDeclType(cast<TypeDecl>(TD))->isFunctionType();
+    QualType TDType = QualType::getFromOpaquePtr(DS.getTypeRep());
+    isFunc = TDType->isFunctionType();
   }
 
   bool isInstField = ((DS.getStorageClassSpec() == DeclSpec::SCS_unspecified ||
@@ -696,7 +696,7 @@
     return Diag(IdLoc, diag::err_mem_init_not_member_or_class)
       << MemberOrBase << SourceRange(IdLoc, RParenLoc);
   
-  QualType BaseType = Context.getTypeDeclType((TypeDecl *)BaseTy);
+  QualType BaseType = QualType::getFromOpaquePtr(BaseTy);
   if (!BaseType->isRecordType())
     return Diag(IdLoc, diag::err_base_init_does_not_name_class)
       << BaseType << SourceRange(IdLoc, RParenLoc);
@@ -1149,10 +1149,10 @@
   //   (7.1.3); however, a typedef-name that names a class shall not
   //   be used as the identifier in the declarator for a destructor
   //   declaration.
-  TypeDecl *DeclaratorTypeD = (TypeDecl *)D.getDeclaratorIdType();
-  if (const TypedefDecl *TypedefD = dyn_cast<TypedefDecl>(DeclaratorTypeD)) {
+  QualType DeclaratorType = QualType::getFromOpaquePtr(D.getDeclaratorIdType());
+  if (DeclaratorType->getAsTypedefType()) {
     Diag(D.getIdentifierLoc(),  diag::err_destructor_typedef_name)
-      << TypedefD->getDeclName();
+      << DeclaratorType;
     isInvalid = true;
   }