Add support for ObjC keyword selectors.

- Add SelectorInfo/SelectorTable classes, modeled after IdentifierInfo/IdentifierTable.
- Add SelectorTable instance to ASTContext, created lazily through ASTContext::getSelectorInfo().
- Add SelectorInfo slot to ObjcMethodDecl.
- Add helper function to derive a SelectorInfo from ObjcKeywordInfo.

Misc: Got the Decl stats stuff up and running again...it was missing support for ObjC AST's.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42023 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp
index 89da7dc..df0398c 100644
--- a/AST/ASTContext.cpp
+++ b/AST/ASTContext.cpp
@@ -16,6 +16,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Basic/TargetInfo.h"
 #include "llvm/ADT/SmallVector.h"
+#include "clang/Lex/IdentifierTable.h"
 using namespace clang;
 
 enum FloatingRank {
@@ -44,6 +45,7 @@
   unsigned NumFunctionNP = 0, NumTypeName = 0, NumTagged = 0, NumReference = 0;
   
   unsigned NumTagStruct = 0, NumTagUnion = 0, NumTagEnum = 0, NumTagClass = 0;
+  unsigned NumObjcInterfaces = 0;
   
   for (unsigned i = 0, e = Types.size(); i != e; ++i) {
     Type *T = Types[i];
@@ -74,7 +76,9 @@
       case Decl::Class:  ++NumTagClass; break; 
       case Decl::Enum:   ++NumTagEnum; break;
       }
-    } else {
+    } else if (isa<ObjcInterfaceType>(T))
+      ++NumObjcInterfaces;
+    else {
       assert(0 && "Unknown type!");
     }
   }
@@ -93,12 +97,16 @@
   fprintf(stderr, "      %d union types\n", NumTagUnion);
   fprintf(stderr, "      %d class types\n", NumTagClass);
   fprintf(stderr, "      %d enum types\n", NumTagEnum);
+  fprintf(stderr, "    %d interface types\n", NumObjcInterfaces);
   fprintf(stderr, "Total bytes = %d\n", int(NumBuiltin*sizeof(BuiltinType)+
     NumPointer*sizeof(PointerType)+NumArray*sizeof(ArrayType)+
     NumComplex*sizeof(ComplexType)+NumVector*sizeof(VectorType)+
     NumFunctionP*sizeof(FunctionTypeProto)+
     NumFunctionNP*sizeof(FunctionTypeNoProto)+
     NumTypeName*sizeof(TypedefType)+NumTagged*sizeof(TagType)));
+  
+  if (Selectors)
+    Selectors->PrintStats();
 }
 
 
@@ -801,3 +809,11 @@
   
   return getTagDeclType(CFConstantStringTypeDecl);
 }
+
+SelectorInfo &ASTContext::getSelectorInfo(const char *NameStart, 
+                                          const char *NameEnd) {
+  if (!Selectors) // create the table lazily
+    Selectors = new SelectorTable();
+  return Selectors->get(NameStart, NameEnd);
+}
+