The goal of this commit is to get just enough Sema support to recognize Objective-C classes
as types. That said, the AST nodes ObjcInterfaceDecl, ObjcInterfaceType, and ObjcClassDecl are *very*
preliminary.

The good news is we no longer need -parse-noop (aka MinimalActions) to parse cocoa.m.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41752 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index f2a8f4d..50cde4e 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -26,7 +26,11 @@
 using namespace clang;
 
 Sema::DeclTy *Sema::isTypeName(const IdentifierInfo &II, Scope *S) const {
-  return dyn_cast_or_null<TypedefDecl>(II.getFETokenInfo<Decl>());
+  Decl *IIDecl = II.getFETokenInfo<Decl>();
+  if (dyn_cast_or_null<TypedefDecl>(IIDecl) || 
+      dyn_cast_or_null<ObjcInterfaceDecl>(IIDecl))
+    return IIDecl;
+  return 0;
 }
 
 void Sema::PopScope(SourceLocation Loc, Scope *S) {
@@ -835,6 +839,45 @@
   return NewTD;
 }
 
+Sema::DeclTy *Sema::ObjcStartClassInterface(SourceLocation AtInterfaceLoc,
+                    IdentifierInfo *ClassName, SourceLocation ClassLoc,
+                    IdentifierInfo *SuperName, SourceLocation SuperLoc,
+                    IdentifierInfo **ProtocolNames, unsigned NumProtocols,
+                    AttributeList *AttrList) {
+  assert(ClassName && "Missing class identifier");
+  ObjcInterfaceDecl *IDecl;
+    
+  IDecl = new ObjcInterfaceDecl(AtInterfaceLoc, ClassName);
+  
+  // Chain & install the interface decl into the identifier.
+  IDecl->setNext(ClassName->getFETokenInfo<Decl>());
+  ClassName->setFETokenInfo(IDecl);
+  return IDecl;
+}
+
+/// ObjcClassDeclaration - 
+/// Scope will always be top level file scope. 
+Action::DeclTy *
+Sema::ObjcClassDeclaration(Scope *S, SourceLocation AtClassLoc,
+                           IdentifierInfo **IdentList, unsigned NumElts) {
+  ObjcClassDecl *CDecl = new ObjcClassDecl(AtClassLoc, NumElts);
+
+  for (unsigned i = 0; i != NumElts; ++i) {
+    ObjcInterfaceDecl *IDecl;
+      
+    IDecl = new ObjcInterfaceDecl(SourceLocation(), IdentList[i], true);
+    // Chain & install the interface decl into the identifier.
+    IDecl->setNext(IdentList[i]->getFETokenInfo<Decl>());
+    IdentList[i]->setFETokenInfo(IDecl);
+    
+    // Remember that this needs to be removed when the scope is popped.
+    S->AddDecl(IdentList[i]);
+    
+    CDecl->setInterfaceDecl((int)i, IDecl);
+  }
+  return CDecl;
+}
+
 
 /// ParseTag - This is invoked when we see 'struct foo' or 'struct {'.  In the
 /// former case, Name will be non-null.  In the later case, Name will be null.