summaryrefslogtreecommitdiff
path: root/lib/Edit
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2013-07-18 22:17:33 +0000
committerFariborz Jahanian <fjahanian@apple.com>2013-07-18 22:17:33 +0000
commit44b41b12a44d74341fe7d241bfdf57847b728a62 (patch)
treed08de7b50992008e9edeab735e4b6caf7ef9dc53 /lib/Edit
parent33530b8e99085f736b0af5e1bc8fedaf80b5c90e (diff)
downloadclang-44b41b12a44d74341fe7d241bfdf57847b728a62.tar.gz
ObjectiveC migrator: Remove semicolon after the typedef
declaration when converting to NS_ENUM. This required some code refactoring. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186619 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Edit')
-rw-r--r--lib/Edit/RewriteObjCFoundationAPI.cpp92
1 files changed, 0 insertions, 92 deletions
diff --git a/lib/Edit/RewriteObjCFoundationAPI.cpp b/lib/Edit/RewriteObjCFoundationAPI.cpp
index 68dcd6b7c6..f4206fbd8f 100644
--- a/lib/Edit/RewriteObjCFoundationAPI.cpp
+++ b/lib/Edit/RewriteObjCFoundationAPI.cpp
@@ -355,98 +355,6 @@ bool edit::rewriteToObjCLiteralSyntax(const ObjCMessageExpr *Msg,
return false;
}
-bool edit::rewriteToObjCProperty(const ObjCMethodDecl *Getter,
- const ObjCMethodDecl *Setter,
- const NSAPI &NS, Commit &commit) {
- ASTContext &Context = NS.getASTContext();
- std::string PropertyString = "@property";
- const ParmVarDecl *argDecl = *Setter->param_begin();
- QualType ArgType = Context.getCanonicalType(argDecl->getType());
- Qualifiers::ObjCLifetime propertyLifetime = ArgType.getObjCLifetime();
-
- if (ArgType->isObjCRetainableType() &&
- propertyLifetime == Qualifiers::OCL_Strong) {
- if (const ObjCObjectPointerType *ObjPtrTy =
- ArgType->getAs<ObjCObjectPointerType>()) {
- ObjCInterfaceDecl *IDecl = ObjPtrTy->getObjectType()->getInterface();
- if (IDecl &&
- IDecl->lookupNestedProtocol(&Context.Idents.get("NSCopying")))
- PropertyString += "(copy)";
- }
- }
- else if (propertyLifetime == Qualifiers::OCL_Weak)
- // TODO. More precise determination of 'weak' attribute requires
- // looking into setter's implementation for backing weak ivar.
- PropertyString += "(weak)";
- else
- PropertyString += "(unsafe_unretained)";
-
- // strip off any ARC lifetime qualifier.
- QualType CanResultTy = Context.getCanonicalType(Getter->getResultType());
- if (CanResultTy.getQualifiers().hasObjCLifetime()) {
- Qualifiers Qs = CanResultTy.getQualifiers();
- Qs.removeObjCLifetime();
- CanResultTy = Context.getQualifiedType(CanResultTy.getUnqualifiedType(), Qs);
- }
- PropertyString += " ";
- PropertyString += CanResultTy.getAsString(Context.getPrintingPolicy());
- PropertyString += " ";
- PropertyString += Getter->getNameAsString();
- commit.replace(CharSourceRange::getCharRange(Getter->getLocStart(),
- Getter->getDeclaratorEndLoc()),
- PropertyString);
- SourceLocation EndLoc = Setter->getDeclaratorEndLoc();
- // Get location past ';'
- EndLoc = EndLoc.getLocWithOffset(1);
- commit.remove(CharSourceRange::getCharRange(Setter->getLocStart(), EndLoc));
- return true;
-}
-
-bool edit::rewriteToObjCInterfaceDecl(const ObjCInterfaceDecl *IDecl,
- llvm::SmallVectorImpl<ObjCProtocolDecl*> &ConformingProtocols,
- const NSAPI &NS, Commit &commit) {
- const ObjCList<ObjCProtocolDecl> &Protocols = IDecl->getReferencedProtocols();
- std::string ClassString;
- SourceLocation EndLoc =
- IDecl->getSuperClass() ? IDecl->getSuperClassLoc() : IDecl->getLocation();
-
- if (Protocols.empty()) {
- ClassString = '<';
- for (unsigned i = 0, e = ConformingProtocols.size(); i != e; i++) {
- ClassString += ConformingProtocols[i]->getNameAsString();
- if (i != (e-1))
- ClassString += ", ";
- }
- ClassString += "> ";
- }
- else {
- ClassString = ", ";
- for (unsigned i = 0, e = ConformingProtocols.size(); i != e; i++) {
- ClassString += ConformingProtocols[i]->getNameAsString();
- if (i != (e-1))
- ClassString += ", ";
- }
- ObjCInterfaceDecl::protocol_loc_iterator PL = IDecl->protocol_loc_end() - 1;
- EndLoc = *PL;
- }
-
- commit.insertAfterToken(EndLoc, ClassString);
- return true;
-}
-
-bool edit::rewriteToNSEnumDecl(const EnumDecl *EnumDcl,
- const TypedefDecl *TypedefDcl,
- const NSAPI &NS, Commit &commit) {
- std::string ClassString = "typedef NS_ENUM(NSInteger, ";
- ClassString += TypedefDcl->getIdentifier()->getName();
- ClassString += ')';
- SourceRange R(EnumDcl->getLocStart(), EnumDcl->getLocStart());
- commit.replace(R, ClassString);
- commit.remove(SourceRange(TypedefDcl->getLocStart(), TypedefDcl->getLocEnd()));
- return true;
-
-}
-
/// \brief Returns true if the immediate message arguments of \c Msg should not
/// be rewritten because it will interfere with the rewrite of the parent
/// message expression. e.g.