diff options
author | Steve Naroff <snaroff@apple.com> | 2007-09-17 14:16:13 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2007-09-17 14:16:13 +0000 |
commit | 3f128ad2691d299b96663da85a9e069c4081ea7c (patch) | |
tree | dd6d3313ba38b90d71adfcf7b1d135465b54aaa2 /AST/ASTContext.cpp | |
parent | 3860c11a3f8a862db25014d555745d8cfd3aaec9 (diff) |
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
Diffstat (limited to 'AST/ASTContext.cpp')
-rw-r--r-- | AST/ASTContext.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp index 89da7dc867..df0398cd1b 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 @@ void ASTContext::PrintStats() const { 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 @@ void ASTContext::PrintStats() const { 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 @@ void ASTContext::PrintStats() const { 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 @@ QualType ASTContext::getCFConstantStringType() { 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); +} + |