ObjectiveC migrator. Infer property from getters only

if property name is a valid identifier in the underlying
language. // rdar://15044184

llvm-svn: 191584
This commit is contained in:
Fariborz Jahanian 2013-09-27 22:55:54 +00:00
parent e9d2396c88
commit 5d783df5f7
3 changed files with 19 additions and 1 deletions

View File

@ -761,6 +761,16 @@ static bool AttributesMatch(const Decl *Decl1, const Decl *Decl2) {
return true;
}
static bool IsValidIdentifier(ASTContext &Ctx,
const char *Name) {
if (!isIdentifierHead(Name[0]))
return false;
std::string NameString = Name;
NameString[0] = toLowercase(NameString[0]);
IdentifierInfo *II = &Ctx.Idents.get(NameString);
return II->getTokenID() == tok::identifier;
}
bool ObjCMigrateASTConsumer::migrateProperty(ASTContext &Ctx,
ObjCContainerDecl *D,
ObjCMethodDecl *Method) {
@ -799,7 +809,7 @@ bool ObjCMigrateASTConsumer::migrateProperty(ASTContext &Ctx,
const char *CGetterName = getterNameString.data() + LengthOfPrefix;
// Make sure that first character after "is" or "get" prefix can
// start an identifier.
if (!isIdentifierHead(CGetterName[0]))
if (!IsValidIdentifier(Ctx, CGetterName))
return false;
if (CGetterName[0] && isUppercase(CGetterName[0])) {
getterName = &Ctx.Idents.get(CGetterName);

View File

@ -210,4 +210,8 @@ DEPRECATED
- (NSURL *)init; // No Change
+ (id)alloc; // No Change
- (BOOL)is1stClass; // Not a valid property
- (BOOL)isClass; // This is a valid property 'class' is not a keyword in ObjC
- (BOOL)isDouble; // Not a valid property
@end

View File

@ -210,4 +210,8 @@ DEPRECATED
- (NSURL *)init; // No Change
+ (id)alloc; // No Change
- (BOOL)is1stClass; // Not a valid property
@property (nonatomic, getter=isClass, readonly) BOOL class; // This is a valid property 'class' is not a keyword in ObjC
- (BOOL)isDouble; // Not a valid property
@end