summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2013-07-08 21:42:08 +0000
committerFariborz Jahanian <fjahanian@apple.com>2013-07-08 21:42:08 +0000
commitbfaabe40e7c9a5eb626cf270f845ad96c6029862 (patch)
tree26f7b7eae28317c8c1a32631c7566326650e92ef /clang/lib
parent0176708e85e2a374790fcc340366f5ca6218ca10 (diff)
downloadbcm5719-llvm-bfaabe40e7c9a5eb626cf270f845ad96c6029862.tar.gz
bcm5719-llvm-bfaabe40e7c9a5eb626cf270f845ad96c6029862.zip
[Objective-C migrator] replace candidate user setter/getter with
their equivalent property declaration. wip. llvm-svn: 185873
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/ARCMigrate/ObjCMT.cpp2
-rw-r--r--clang/lib/Edit/Commit.cpp2
-rw-r--r--clang/lib/Edit/RewriteObjCFoundationAPI.cpp28
3 files changed, 29 insertions, 3 deletions
diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp
index ec19f6e8f06..d01dca45a2a 100644
--- a/clang/lib/ARCMigrate/ObjCMT.cpp
+++ b/clang/lib/ARCMigrate/ObjCMT.cpp
@@ -212,7 +212,7 @@ void ObjCMigrateASTConsumer::migrateObjCInterfaceDecl(ASTContext &Ctx,
continue;
const ParmVarDecl *argDecl = *SetterMethod->param_begin();
QualType ArgType = argDecl->getType();
- if (!Ctx.hasSameType(ArgType, GRT))
+ if (!Ctx.hasSameUnqualifiedType(ArgType, GRT))
continue;
edit::Commit commit(*Editor);
edit::rewriteToObjCProperty(Method, SetterMethod, *NSAPIObj, commit);
diff --git a/clang/lib/Edit/Commit.cpp b/clang/lib/Edit/Commit.cpp
index 0b4ea3e0cda..9c08cc28ac9 100644
--- a/clang/lib/Edit/Commit.cpp
+++ b/clang/lib/Edit/Commit.cpp
@@ -183,7 +183,7 @@ void Commit::addInsert(SourceLocation OrigLoc, FileOffset Offs, StringRef text,
data.Kind = Act_Insert;
data.OrigLoc = OrigLoc;
data.Offset = Offs;
- data.Text = text;
+ data.Text = copyString(text);
data.BeforePrev = beforePreviousInsertions;
CachedEdits.push_back(data);
}
diff --git a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp
index 9af53037eac..05abbed14c3 100644
--- a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp
+++ b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp
@@ -358,7 +358,33 @@ bool edit::rewriteToObjCLiteralSyntax(const ObjCMessageExpr *Msg,
bool edit::rewriteToObjCProperty(const ObjCMethodDecl *Getter,
const ObjCMethodDecl *Setter,
const NSAPI &NS, Commit &commit) {
- return false;
+ std::string PropertyString = "@property";
+ const ParmVarDecl *argDecl = *Setter->param_begin();
+ QualType ArgType = argDecl->getType();
+ Qualifiers::ObjCLifetime propertyLifetime = ArgType.getObjCLifetime();
+ if (propertyLifetime != Qualifiers::OCL_None) {
+ PropertyString += "(";
+ if (propertyLifetime == Qualifiers::OCL_Strong)
+ PropertyString += "strong";
+ else if (propertyLifetime == Qualifiers::OCL_Weak)
+ PropertyString += "weak";
+ else
+ PropertyString += "unsafe_unretained";
+ PropertyString += ")";
+ }
+ QualType PropQT = Getter->getResultType();
+ PropertyString += " ";
+ PropertyString += PropQT.getAsString(NS.getASTContext().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;
}
/// \brief Returns true if the immediate message arguments of \c Msg should not
OpenPOWER on IntegriCloud