a forward class declaration matching a typedef name of a class
refers to the underlying class.
This is radar 6859726. Steve, please read the radar for my rational.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71181 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 0e655a4..27f1277 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -1075,6 +1075,13 @@
         Diag(AtClassLoc, diag::err_redefinition_different_kind) << IdentList[i];
         Diag(PrevDecl->getLocation(), diag::note_previous_definition);
       }
+      else if (TDD) {
+        // a forward class declaration matching a typedef name of a class
+        // refers to the underlying class.
+        if (ObjCInterfaceType * OI = 
+              dyn_cast<ObjCInterfaceType>(TDD->getUnderlyingType()))
+          PrevDecl = OI->getDecl();
+      }
     }
     ObjCInterfaceDecl *IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl); 
     if (!IDecl) {  // Not already seen?  Make a forward decl.