aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AST/ASTContext.cpp11
-rw-r--r--AST/Expr.cpp8
-rw-r--r--Lex/IdentifierTable.cpp31
-rw-r--r--Sema/SemaDecl.cpp8
-rw-r--r--Sema/SemaExpr.cpp12
-rw-r--r--include/clang/AST/ASTContext.h13
-rw-r--r--include/clang/AST/Decl.h7
-rw-r--r--include/clang/AST/Expr.h10
-rw-r--r--include/clang/Lex/IdentifierTable.h48
9 files changed, 23 insertions, 125 deletions
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp
index df0398cd1b..6420f0f051 100644
--- a/AST/ASTContext.cpp
+++ b/AST/ASTContext.cpp
@@ -104,9 +104,6 @@ void ASTContext::PrintStats() const {
NumFunctionP*sizeof(FunctionTypeProto)+
NumFunctionNP*sizeof(FunctionTypeNoProto)+
NumTypeName*sizeof(TypedefType)+NumTagged*sizeof(TagType)));
-
- if (Selectors)
- Selectors->PrintStats();
}
@@ -809,11 +806,3 @@ 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);
-}
-
diff --git a/AST/Expr.cpp b/AST/Expr.cpp
index 08773e86d0..e5a128247e 100644
--- a/AST/Expr.cpp
+++ b/AST/Expr.cpp
@@ -858,7 +858,7 @@ unsigned OCUVectorElementExpr::getEncodedElementAccess() const {
// constructor for unary messages.
ObjCMessageExpr::ObjCMessageExpr(
- IdentifierInfo *clsName, SelectorInfo &methName, QualType retType,
+ IdentifierInfo *clsName, IdentifierInfo &methName, QualType retType,
SourceLocation LBrac, SourceLocation RBrac)
: Expr(ObjCMessageExprClass, retType), Selector(methName) {
ClassName = clsName;
@@ -867,7 +867,7 @@ ObjCMessageExpr::ObjCMessageExpr(
}
ObjCMessageExpr::ObjCMessageExpr(
- Expr *fn, SelectorInfo &methName, QualType retType,
+ Expr *fn, IdentifierInfo &methName, QualType retType,
SourceLocation LBrac, SourceLocation RBrac)
: Expr(ObjCMessageExprClass, retType), Selector(methName), ClassName(0) {
SubExprs = new Expr*[1];
@@ -878,7 +878,7 @@ ObjCMessageExpr::ObjCMessageExpr(
// constructor for keyword messages.
ObjCMessageExpr::ObjCMessageExpr(
- Expr *fn, SelectorInfo &selInfo, ObjcKeywordMessage *keys, unsigned numargs,
+ Expr *fn, IdentifierInfo &selInfo, ObjcKeywordMessage *keys, unsigned numargs,
QualType retType, SourceLocation LBrac, SourceLocation RBrac)
: Expr(ObjCMessageExprClass, retType), Selector(selInfo), ClassName(0) {
SubExprs = new Expr*[numargs+1];
@@ -890,7 +890,7 @@ ObjCMessageExpr::ObjCMessageExpr(
}
ObjCMessageExpr::ObjCMessageExpr(
- IdentifierInfo *clsName, SelectorInfo &selInfo, ObjcKeywordMessage *keys,
+ IdentifierInfo *clsName, IdentifierInfo &selInfo, ObjcKeywordMessage *keys,
unsigned numargs, QualType retType, SourceLocation LBrac, SourceLocation RBrac)
: Expr(ObjCMessageExprClass, retType), Selector(selInfo), ClassName(clsName) {
SubExprs = new Expr*[numargs+1];
diff --git a/Lex/IdentifierTable.cpp b/Lex/IdentifierTable.cpp
index c1c00d232b..d3faeb58db 100644
--- a/Lex/IdentifierTable.cpp
+++ b/Lex/IdentifierTable.cpp
@@ -209,34 +209,3 @@ void IdentifierTable::PrintStats() const {
// Compute statistics about the memory allocated for identifiers.
HashTable.getAllocator().PrintStats();
}
-
-/// PrintStats - Print statistics about how well the identifier table is doing
-/// at hashing identifiers.
-void SelectorTable::PrintStats() const {
- unsigned NumBuckets = HashTable.getNumBuckets();
- unsigned NumIdentifiers = HashTable.getNumItems();
- unsigned NumEmptyBuckets = NumBuckets-NumIdentifiers;
- unsigned AverageIdentifierSize = 0;
- unsigned MaxIdentifierLength = 0;
-
- // TODO: Figure out maximum times an identifier had to probe for -stats.
- for (llvm::StringMap<SelectorInfo, llvm::BumpPtrAllocator>::const_iterator
- I = HashTable.begin(), E = HashTable.end(); I != E; ++I) {
- unsigned IdLen = I->getKeyLength();
- AverageIdentifierSize += IdLen;
- if (MaxIdentifierLength < IdLen)
- MaxIdentifierLength = IdLen;
- }
-
- fprintf(stderr, "\n*** Selector Table Stats:\n");
- fprintf(stderr, "# Selectors: %d\n", NumIdentifiers);
- fprintf(stderr, "# Empty Buckets: %d\n", NumEmptyBuckets);
- fprintf(stderr, "Hash density (#selectors per bucket): %f\n",
- NumIdentifiers/(double)NumBuckets);
- fprintf(stderr, "Ave selector length: %f\n",
- (AverageIdentifierSize/(double)NumIdentifiers));
- fprintf(stderr, "Max selector length: %d\n", MaxIdentifierLength);
-
- // Compute statistics about the memory allocated for identifiers.
- HashTable.getAllocator().PrintStats();
-}
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index 3742702058..42024b1adb 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -1308,8 +1308,8 @@ Sema::DeclTy *Sema::ObjcBuildMethodDeclaration(SourceLocation MethodLoc,
methodName += ":";
}
methodName[len] = '\0';
- SelectorInfo &SelName = Context.getSelectorInfo(&methodName[0],
- &methodName[0]+len);
+ IdentifierInfo &SelName = Context.Idents.get(&methodName[0],
+ &methodName[0]+len);
llvm::SmallVector<ParmVarDecl*, 16> Params;
for (unsigned i = 0; i < NumKeywords; i++) {
@@ -1340,8 +1340,8 @@ Sema::DeclTy *Sema::ObjcBuildMethodDeclaration(SourceLocation MethodLoc,
IdentifierInfo *SelectorName, AttributeList *AttrList,
tok::ObjCKeywordKind MethodDeclKind) {
const char *methodName = SelectorName->getName();
- SelectorInfo &SelName = Context.getSelectorInfo(methodName,
- methodName+strlen(methodName));
+ IdentifierInfo &SelName = Context.Idents.get(methodName,
+ methodName+strlen(methodName));
QualType resultDeclType = QualType::getFromOpaquePtr(ReturnType);
ObjcMethodDecl* ObjcMethod = new ObjcMethodDecl(MethodLoc,
SelName, resultDeclType, 0, -1,
diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp
index 886b3dd5bd..11c3eccb36 100644
--- a/Sema/SemaExpr.cpp
+++ b/Sema/SemaExpr.cpp
@@ -1857,7 +1857,7 @@ Sema::ExprResult Sema::ParseObjCEncodeExpression(SourceLocation AtLoc,
return new ObjCEncodeExpr(t, EncodedType, AtLoc, RParenLoc);
}
-static SelectorInfo &DeriveSelector(ObjcKeywordMessage *Keywords,
+static IdentifierInfo &DeriveSelector(ObjcKeywordMessage *Keywords,
unsigned NumKeywords,
ASTContext &Context) {
// Derive the selector name from the keyword declarations.
@@ -1875,7 +1875,7 @@ static SelectorInfo &DeriveSelector(ObjcKeywordMessage *Keywords,
methodName += ":";
}
methodName[len] = '\0';
- return Context.getSelectorInfo(&methodName[0], &methodName[0]+len);
+ return Context.Idents.get(&methodName[0], &methodName[0]+len);
}
// This actions handles keyword message to classes.
@@ -1884,7 +1884,7 @@ Sema::ExprResult Sema::ActOnKeywordMessage(
ObjcKeywordMessage *Keywords, unsigned NumKeywords,
SourceLocation lbrac, SourceLocation rbrac)
{
- SelectorInfo &SelName = DeriveSelector(Keywords, NumKeywords, Context);
+ IdentifierInfo &SelName = DeriveSelector(Keywords, NumKeywords, Context);
assert(receivingClassName && "missing receiver class name");
return new ObjCMessageExpr(receivingClassName, SelName, Keywords, NumKeywords,
@@ -1895,7 +1895,7 @@ Sema::ExprResult Sema::ActOnKeywordMessage(
Sema::ExprResult Sema::ActOnKeywordMessage(
ExprTy *receiver, ObjcKeywordMessage *Keywords, unsigned NumKeywords,
SourceLocation lbrac, SourceLocation rbrac) {
- SelectorInfo &SelName = DeriveSelector(Keywords, NumKeywords, Context);
+ IdentifierInfo &SelName = DeriveSelector(Keywords, NumKeywords, Context);
assert(receiver && "missing receiver expression");
Expr *RExpr = static_cast<Expr *>(receiver);
@@ -1910,7 +1910,7 @@ Sema::ExprResult Sema::ActOnUnaryMessage(
assert(receivingClassName && "missing receiver class name");
// FIXME: this should be passed in...
- SelectorInfo &SName = Context.getSelectorInfo(
+ IdentifierInfo &SName = Context.Idents.get(
selName->getName(), selName->getName()+strlen(selName->getName()));
return new ObjCMessageExpr(receivingClassName, SName,
Context.IntTy/*FIXME*/, lbrac, rbrac);
@@ -1924,7 +1924,7 @@ Sema::ExprResult Sema::ActOnUnaryMessage(
Expr *RExpr = static_cast<Expr *>(receiver);
// FIXME: this should be passed in...
- SelectorInfo &SName = Context.getSelectorInfo(
+ IdentifierInfo &SName = Context.Idents.get(
selName->getName(), selName->getName()+strlen(selName->getName()));
return new ObjCMessageExpr(RExpr, SName,
Context.IntTy/*FIXME*/, lbrac, rbrac);
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index 5d753aa6fc..76a51fc254 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -24,7 +24,6 @@
namespace clang {
class TargetInfo;
- class SelectorTable;
/// ASTContext - This class holds long-lived AST nodes (such as types and
/// decls) that can be referred to throughout the semantic analysis of a file.
@@ -39,7 +38,6 @@ class ASTContext {
llvm::FoldingSet<FunctionTypeProto> FunctionTypeProtos;
llvm::DenseMap<const RecordDecl*, const RecordLayout*> RecordLayoutInfo;
RecordDecl *CFConstantStringTypeDecl;
- SelectorTable *Selectors;
public:
SourceManager &SourceMgr;
TargetInfo &Target;
@@ -57,8 +55,7 @@ public:
QualType FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy;
ASTContext(SourceManager &SM, TargetInfo &t, IdentifierTable &idents) :
- CFConstantStringTypeDecl(0), Selectors(0),
- SourceMgr(SM), Target(t), Idents(idents) {
+ CFConstantStringTypeDecl(0), SourceMgr(SM), Target(t), Idents(idents) {
InitBuiltinTypes();
BuiltinInfo.InitializeBuiltins(idents, Target);
}
@@ -179,14 +176,6 @@ public:
/// 'typeSize' is a real floating point or complex type.
QualType getFloatingTypeOfSizeWithinDomain(QualType typeSize,
QualType typeDomain) const;
-
- //===--------------------------------------------------------------------===//
- // Objective-C
- //===--------------------------------------------------------------------===//
-
- /// getSelectorInfo - Return a uniqued character string for the selector.
- SelectorInfo &getSelectorInfo(const char *NameStart, const char *NameEnd);
-
private:
ASTContext(const ASTContext&); // DO NOT IMPLEMENT
void operator=(const ASTContext&); // DO NOT IMPLEMENT
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index aea0dc822b..67f5ebd756 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -26,7 +26,6 @@ class FunctionDecl;
class AttributeList;
class ObjcIvarDecl;
class ObjcMethodDecl;
-class SelectorInfo;
/// Decl - This represents one declaration (or definition), e.g. a variable,
@@ -618,7 +617,7 @@ public:
enum ImplementationControl { None, Required, Optional };
private:
// A unigue name for this method.
- SelectorInfo &Selector;
+ IdentifierInfo &Selector;
// Type of this method.
QualType MethodDeclType;
@@ -636,7 +635,7 @@ private:
ImplementationControl DeclImplementation : 2;
public:
- ObjcMethodDecl(SourceLocation L, SelectorInfo &SelId, QualType T,
+ ObjcMethodDecl(SourceLocation L, IdentifierInfo &SelId, QualType T,
ParmVarDecl **paramInfo = 0, int numParams=-1,
AttributeList *M = 0, bool isInstance = true,
Decl *PrevDecl = 0)
@@ -644,7 +643,7 @@ public:
ParamInfo(paramInfo), NumMethodParams(numParams),
MethodAttrs(M), IsInstance(isInstance) {}
- ObjcMethodDecl(Kind DK, SourceLocation L, SelectorInfo &SelId, QualType T,
+ ObjcMethodDecl(Kind DK, SourceLocation L, IdentifierInfo &SelId, QualType T,
ParmVarDecl **paramInfo = 0, int numParams=-1,
AttributeList *M = 0, bool isInstance = true,
Decl *PrevDecl = 0)
diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 84d9a791b9..24eecf597c 100644
--- a/include/clang/AST/Expr.h
+++ b/include/clang/AST/Expr.h
@@ -1068,7 +1068,7 @@ class ObjCMessageExpr : public Expr {
unsigned NumArgs;
// A unigue name for this message.
- SelectorInfo &Selector;
+ IdentifierInfo &Selector;
IdentifierInfo **KeyIdents;
@@ -1078,17 +1078,17 @@ class ObjCMessageExpr : public Expr {
public:
// constructor for unary messages.
// FIXME: clsName should be typed to ObjCInterfaceType
- ObjCMessageExpr(IdentifierInfo *clsName, SelectorInfo &selInfo,
+ ObjCMessageExpr(IdentifierInfo *clsName, IdentifierInfo &selInfo,
QualType retType, SourceLocation LBrac, SourceLocation RBrac);
- ObjCMessageExpr(Expr *receiver, SelectorInfo &selInfo,
+ ObjCMessageExpr(Expr *receiver, IdentifierInfo &selInfo,
QualType retType, SourceLocation LBrac, SourceLocation RBrac);
// constructor for keyword messages.
// FIXME: clsName should be typed to ObjCInterfaceType
- ObjCMessageExpr(IdentifierInfo *clsName, SelectorInfo &selInfo,
+ ObjCMessageExpr(IdentifierInfo *clsName, IdentifierInfo &selInfo,
ObjcKeywordMessage *keys, unsigned numargs, QualType retType,
SourceLocation LBrac, SourceLocation RBrac);
- ObjCMessageExpr(Expr *receiver, SelectorInfo &selInfo,
+ ObjCMessageExpr(Expr *receiver, IdentifierInfo &selInfo,
ObjcKeywordMessage *keys, unsigned numargs, QualType retType,
SourceLocation LBrac, SourceLocation RBrac);
~ObjCMessageExpr() {
diff --git a/include/clang/Lex/IdentifierTable.h b/include/clang/Lex/IdentifierTable.h
index 9a6a93ec36..fd2cb6ae71 100644
--- a/include/clang/Lex/IdentifierTable.h
+++ b/include/clang/Lex/IdentifierTable.h
@@ -166,54 +166,6 @@ private:
void AddKeywords(const LangOptions &LangOpts);
};
-/// SelectorInfo - One of these records is kept for each selector. Selectors
-/// are created as a by-product of parsing a method declaration/definition,
-/// message expression, or @selector expression.
-class SelectorInfo {
- void *ObjcMethodDecl; // FIXME: add setter/getter.
-
- SelectorInfo(const SelectorInfo&); // NONCOPYABLE.
-public:
- SelectorInfo() : ObjcMethodDecl(0) {}
-
- /// getName - Return the actual string for this selector. The returned
- /// string is properly null terminated.
- ///
- const char *getName() const {
- // String data is stored immediately after the IdentifierInfo object.
- return (const char*)(this+1);
- }
-};
-
-/// SelectorTable - This table implements an efficient mapping from strings to
-/// SelectorInfo nodes.
-class SelectorTable {
- // Shark shows that using MallocAllocator is *much* slower than using this
- // BumpPtrAllocator!
- typedef llvm::StringMap<SelectorInfo, llvm::BumpPtrAllocator> HashTableTy;
- HashTableTy HashTable;
-public:
- SelectorTable() : HashTable(4096) { }
-
- /// get - Return the selector info for the specified name.
- ///
- SelectorInfo &get(const char *NameStart, const char *NameEnd) {
- return HashTable.GetOrCreateValue(NameStart, NameEnd).getValue();
- }
- SelectorInfo &get(const char *Name) {
- return get(Name, Name+strlen(Name));
- }
- typedef HashTableTy::const_iterator iterator;
- typedef HashTableTy::const_iterator const_iterator;
-
- iterator begin() const { return HashTable.begin(); }
- iterator end() const { return HashTable.end(); }
-
- /// PrintStats - Print some statistics to stderr that indicate how well the
- /// hashing is doing.
- void PrintStats() const;
-};
-
} // end namespace clang
#endif