Change our basic strategy for avoiding deprecation warnings when the decl use
appears in a deprecated context.  In the new strategy, we emit the warnings
as usual unless we're currently parsing a declaration, where "declaration" is
restricted to mean a decl group or a few special cases in Objective C.  If
we *are* parsing a declaration, we queue up the deprecation warnings until
the declaration has been completely parsed, and then emit them only if the
decl is not deprecated.
We also standardize the bookkeeping for deprecation so as to avoid special cases.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85998 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 94b74fb..0003b1b 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -67,16 +67,6 @@
   return false;
 }
 
-/// isDeclaratorDeprecated - Return true if the declarator is deprecated.
-/// We do not want to warn about use of deprecated types (e.g. typedefs) when
-/// defining a declaration that is itself deprecated.
-static bool isDeclaratorDeprecated(const Declarator &D) {
-  for (const AttributeList *AL = D.getAttributes(); AL; AL = AL->getNext())
-    if (AL->getKind() == AttributeList::AT_deprecated)
-      return true;
-  return false;
-}
-
 /// \brief Convert the specified declspec to the appropriate type
 /// object.
 /// \param D  the declarator containing the declaration specifier.
@@ -247,8 +237,7 @@
     }
 
     // If the type is deprecated or unavailable, diagnose it.
-    TheSema.DiagnoseUseOfDecl(D, DS.getTypeSpecTypeLoc(),
-                              isDeclaratorDeprecated(TheDeclarator));
+    TheSema.DiagnoseUseOfDecl(D, DS.getTypeSpecTypeLoc());
     
     assert(DS.getTypeSpecWidth() == 0 && DS.getTypeSpecComplex() == 0 &&
            DS.getTypeSpecSign() == 0 && "No qualifiers on tag names!");
@@ -303,27 +292,6 @@
       }
     }
 
-    // If this is a reference to an invalid typedef, propagate the invalidity.
-    if (TypedefType *TDT = dyn_cast<TypedefType>(Result)) {
-      if (TDT->getDecl()->isInvalidDecl())
-        TheDeclarator.setInvalidType(true);
-      
-      // If the type is deprecated or unavailable, diagnose it.
-      TheSema.DiagnoseUseOfDecl(TDT->getDecl(), DS.getTypeSpecTypeLoc(),
-                                isDeclaratorDeprecated(TheDeclarator));
-    } else if (ObjCInterfaceType *OIT = dyn_cast<ObjCInterfaceType>(Result)) {
-      // If the type is deprecated or unavailable, diagnose it.
-      TheSema.DiagnoseUseOfDecl(OIT->getDecl(), DS.getTypeSpecTypeLoc(),
-                                isDeclaratorDeprecated(TheDeclarator));
-    } else if (ObjCObjectPointerType *DPT =
-                 dyn_cast<ObjCObjectPointerType>(Result)) {
-      // If the type is deprecated or unavailable, diagnose it.
-      if (ObjCInterfaceDecl *D = DPT->getInterfaceDecl())
-        TheSema.DiagnoseUseOfDecl(D, DS.getTypeSpecTypeLoc(),
-                                  isDeclaratorDeprecated(TheDeclarator));
-    }
-
-
     // TypeQuals handled by caller.
     break;
   }