forked from OSchip/llvm-project
address some comments on r183474:
- factor the name construction part out from constructSetterName - rename constructSetterName to the more appropriate constructSetterSelector no functionality change intended. rdar://problem/14035789 llvm-svn: 183582
This commit is contained in:
parent
fa5f6f7440
commit
a4ce906bc0
|
@ -19,6 +19,7 @@
|
|||
#include "clang/Basic/LLVM.h"
|
||||
#include "clang/Basic/OperatorKinds.h"
|
||||
#include "clang/Basic/TokenKinds.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/PointerLikeTypeTraits.h"
|
||||
|
@ -725,13 +726,19 @@ public:
|
|||
/// \brief Return the total amount of memory allocated for managing selectors.
|
||||
size_t getTotalMemory() const;
|
||||
|
||||
/// \brief Return the setter name for the given identifier.
|
||||
/// \brief Return the default setter name for the given identifier.
|
||||
///
|
||||
/// This is "set" + \p Name where the initial character of \p Name
|
||||
/// has been capitalized.
|
||||
static Selector constructSetterName(IdentifierTable &Idents,
|
||||
SelectorTable &SelTable,
|
||||
const IdentifierInfo *Name);
|
||||
static SmallString<100> constructSetterName(StringRef Name);
|
||||
|
||||
/// \brief Return the default setter selector for the given identifier.
|
||||
///
|
||||
/// This is "set" + \p Name where the initial character of \p Name
|
||||
/// has been capitalized.
|
||||
static Selector constructSetterSelector(IdentifierTable &Idents,
|
||||
SelectorTable &SelTable,
|
||||
const IdentifierInfo *Name);
|
||||
};
|
||||
|
||||
/// DeclarationNameExtra - Common base of the MultiKeywordSelector,
|
||||
|
|
|
@ -13,11 +13,10 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/Basic/IdentifierTable.h"
|
||||
#include "clang/Basic/CharInfo.h"
|
||||
#include "clang/Basic/LangOptions.h"
|
||||
#include "clang/Basic/CharInfo.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <cstdio>
|
||||
|
@ -464,15 +463,20 @@ static SelectorTableImpl &getSelectorTableImpl(void *P) {
|
|||
return *static_cast<SelectorTableImpl*>(P);
|
||||
}
|
||||
|
||||
/*static*/ Selector
|
||||
SelectorTable::constructSetterName(IdentifierTable &Idents,
|
||||
SelectorTable &SelTable,
|
||||
const IdentifierInfo *Name) {
|
||||
SmallString<100> SelectorName;
|
||||
SelectorName = "set";
|
||||
SelectorName += Name->getName();
|
||||
/*static*/ SmallString<100>
|
||||
SelectorTable::constructSetterName(StringRef Name) {
|
||||
SmallString<100> SelectorName("set");
|
||||
SelectorName += Name;
|
||||
SelectorName[3] = toUppercase(SelectorName[3]);
|
||||
IdentifierInfo *SetterName = &Idents.get(SelectorName);
|
||||
return SelectorName;
|
||||
}
|
||||
|
||||
/*static*/ Selector
|
||||
SelectorTable::constructSetterSelector(IdentifierTable &Idents,
|
||||
SelectorTable &SelTable,
|
||||
const IdentifierInfo *Name) {
|
||||
IdentifierInfo *SetterName =
|
||||
&Idents.get(constructSetterName(Name->getName()));
|
||||
return SelTable.getUnarySelector(SetterName);
|
||||
}
|
||||
|
||||
|
|
|
@ -1472,12 +1472,7 @@ static bool hasDefaultSetterName(const ObjCPropertyDecl *PD,
|
|||
return true;
|
||||
|
||||
assert(Setter->getDeclName().isObjCOneArgSelector());
|
||||
// Construct a setter name like SelectorTable::constructSetterName()
|
||||
// does, but without entering it into the table.
|
||||
SmallString<100> DefaultName("set");
|
||||
DefaultName += PD->getName();
|
||||
DefaultName[3] = toUppercase(DefaultName[3]);
|
||||
return DefaultName ==
|
||||
return SelectorTable::constructSetterName(PD->getName()) ==
|
||||
Setter->getDeclName().getObjCSelector().getNameForSlot(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -348,9 +348,10 @@ public:
|
|||
if (SetterName)
|
||||
SetterSel = P.PP.getSelectorTable().getSelector(1, &SetterName);
|
||||
else
|
||||
SetterSel = SelectorTable::constructSetterName(P.PP.getIdentifierTable(),
|
||||
P.PP.getSelectorTable(),
|
||||
FD.D.getIdentifier());
|
||||
SetterSel =
|
||||
SelectorTable::constructSetterSelector(P.PP.getIdentifierTable(),
|
||||
P.PP.getSelectorTable(),
|
||||
FD.D.getIdentifier());
|
||||
bool isOverridingProperty = false;
|
||||
Decl *Property =
|
||||
P.Actions.ActOnProperty(P.getCurScope(), AtLoc, LParenLoc,
|
||||
|
|
|
@ -1362,8 +1362,9 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr,
|
|||
if (DiagnoseUseOfDecl(OMD, MemberLoc))
|
||||
return ExprError();
|
||||
Selector SetterSel =
|
||||
SelectorTable::constructSetterName(PP.getIdentifierTable(),
|
||||
PP.getSelectorTable(), Member);
|
||||
SelectorTable::constructSetterSelector(PP.getIdentifierTable(),
|
||||
PP.getSelectorTable(),
|
||||
Member);
|
||||
ObjCMethodDecl *SMD = 0;
|
||||
if (Decl *SDecl = FindGetterSetterNameDecl(OPT, /*Property id*/0,
|
||||
SetterSel, Context))
|
||||
|
@ -1410,8 +1411,9 @@ Sema::LookupMemberExpr(LookupResult &R, ExprResult &BaseExpr,
|
|||
// 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.
|
||||
Selector SetterSel =
|
||||
SelectorTable::constructSetterName(PP.getIdentifierTable(),
|
||||
PP.getSelectorTable(), Member);
|
||||
SelectorTable::constructSetterSelector(PP.getIdentifierTable(),
|
||||
PP.getSelectorTable(),
|
||||
Member);
|
||||
ObjCMethodDecl *Setter = IFace->lookupClassMethod(SetterSel);
|
||||
if (!Setter) {
|
||||
// If this reference is in an @implementation, also check for 'private'
|
||||
|
|
|
@ -1552,8 +1552,8 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT,
|
|||
// 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.
|
||||
Selector SetterSel =
|
||||
SelectorTable::constructSetterName(PP.getIdentifierTable(),
|
||||
PP.getSelectorTable(), Member);
|
||||
SelectorTable::constructSetterSelector(PP.getIdentifierTable(),
|
||||
PP.getSelectorTable(), Member);
|
||||
ObjCMethodDecl *Setter = IFace->lookupInstanceMethod(SetterSel);
|
||||
|
||||
// May be founf in property's qualified list.
|
||||
|
@ -1699,8 +1699,9 @@ ActOnClassPropertyRefExpr(IdentifierInfo &receiverName,
|
|||
|
||||
// Look for the matching setter, in case it is needed.
|
||||
Selector SetterSel =
|
||||
SelectorTable::constructSetterName(PP.getIdentifierTable(),
|
||||
PP.getSelectorTable(), &propertyName);
|
||||
SelectorTable::constructSetterSelector(PP.getIdentifierTable(),
|
||||
PP.getSelectorTable(),
|
||||
&propertyName);
|
||||
|
||||
ObjCMethodDecl *Setter = IFace->lookupClassMethod(SetterSel);
|
||||
if (!Setter) {
|
||||
|
|
|
@ -575,9 +575,9 @@ bool ObjCPropertyOpBuilder::findSetter(bool warn) {
|
|||
RefExpr->getImplicitPropertyGetter()->getSelector()
|
||||
.getIdentifierInfoForSlot(0);
|
||||
SetterSelector =
|
||||
SelectorTable::constructSetterName(S.PP.getIdentifierTable(),
|
||||
S.PP.getSelectorTable(),
|
||||
getterName);
|
||||
SelectorTable::constructSetterSelector(S.PP.getIdentifierTable(),
|
||||
S.PP.getSelectorTable(),
|
||||
getterName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue