From: Steve Naroff Date: Tue, 10 Mar 2009 17:24:38 +0000 (+0000) Subject: Simplify SelectorTable::constructSetterName() usage... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fdc92b7877535e6264fe43cfbdc8f01e9b224f81;p=clang Simplify SelectorTable::constructSetterName() usage... git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66551 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/IdentifierTable.h b/include/clang/Basic/IdentifierTable.h index df0200f1e7..70e1cbfdd3 100644 --- a/include/clang/Basic/IdentifierTable.h +++ b/include/clang/Basic/IdentifierTable.h @@ -435,13 +435,16 @@ public: /// constructSetterName - Return the setter name for the given /// identifier, i.e. "set" + Name where the initial character of Name /// has been capitalized. - static IdentifierInfo *constructSetterName(IdentifierTable &Idents, - const IdentifierInfo *Name) { + static Selector constructSetterName(IdentifierTable &Idents, + SelectorTable &SelTable, + const IdentifierInfo *Name) { llvm::SmallString<100> SelectorName; SelectorName = "set"; SelectorName.append(Name->getName(), Name->getName()+Name->getLength()); SelectorName[3] = toupper(SelectorName[3]); - return &Idents.get(&SelectorName[0], &SelectorName[SelectorName.size()]); + IdentifierInfo *SetterName = + &Idents.get(&SelectorName[0], &SelectorName[SelectorName.size()]); + return SelTable.getUnarySelector(SetterName); } // Emit - Emit a SelectorTable to bitcode. diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 8a3672d29c..293fe257cc 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -328,11 +328,12 @@ void Parser::ParseObjCInterfaceDeclList(DeclTy *interfaceDecl, PP.getSelectorTable().getNullarySelector(SelName); IdentifierInfo *SetterName = OCDS.getSetterName(); if (!SetterName) - SetterName = - SelectorTable::constructSetterName(PP.getIdentifierTable(), - FD.D.getIdentifier()); + SetterName = FD.D.getIdentifier(); + Selector SetterSel = - PP.getSelectorTable().getUnarySelector(SetterName); + SelectorTable::constructSetterName(PP.getIdentifierTable(), + PP.getSelectorTable(), + SetterName); bool isOverridingProperty = false; DeclTy *Property = Actions.ActOnProperty(CurScope, AtLoc, FD, OCDS, GetterSel, SetterSel, diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index f37c0d5bad..df8afa450b 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -1886,10 +1886,9 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, // If we found a getter then this may be a valid dot-reference, we // will look for the matching setter, in case it is needed. - IdentifierInfo *SetterName = - SelectorTable::constructSetterName(PP.getIdentifierTable(), &Member); - - Selector SetterSel = PP.getSelectorTable().getUnarySelector(SetterName); + Selector SetterSel = + SelectorTable::constructSetterName(PP.getIdentifierTable(), + PP.getSelectorTable(), &Member); ObjCMethodDecl *Setter = IFace->lookupInstanceMethod(SetterSel); if (!Setter) { // If this reference is in an @implementation, also check for 'private' diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 98fbd96331..ce9fe89719 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -298,10 +298,10 @@ Action::OwningExprResult Sema::ActOnClassPropertyRefExpr( } // Look for the matching setter, in case it is needed. - IdentifierInfo *SetterName = - SelectorTable::constructSetterName(PP.getIdentifierTable(), &propertyName); + Selector SetterSel = + SelectorTable::constructSetterName(PP.getIdentifierTable(), + PP.getSelectorTable(), &propertyName); - Selector SetterSel = PP.getSelectorTable().getUnarySelector(SetterName); ObjCMethodDecl *Setter = IFace->lookupClassMethod(SetterSel); if (!Setter) { // If this reference is in an @implementation, also check for 'private'