diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2013-07-18 22:17:33 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-07-18 22:17:33 +0000 |
commit | 85e988bbeaa0b77729cd631fd60318446ce81631 (patch) | |
tree | 46300ce28f81c6928811cc5edf3f2a6e923ef53d /clang/lib/Edit/RewriteObjCFoundationAPI.cpp | |
parent | 4d56e9c1cb7c010ed1bccff952fc5c879bd1aba6 (diff) | |
download | llvm-85e988bbeaa0b77729cd631fd60318446ce81631.zip llvm-85e988bbeaa0b77729cd631fd60318446ce81631.tar.gz llvm-85e988bbeaa0b77729cd631fd60318446ce81631.tar.bz2 |
ObjectiveC migrator: Remove semicolon after the typedef
declaration when converting to NS_ENUM. This required
some code refactoring.
llvm-svn: 186619
Diffstat (limited to 'clang/lib/Edit/RewriteObjCFoundationAPI.cpp')
-rw-r--r-- | clang/lib/Edit/RewriteObjCFoundationAPI.cpp | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp index 68dcd6b..f4206fb 100644 --- a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp +++ b/clang/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. |