[cfe-commits] r143882 - in /cfe/trunk/lib/ARCMigrate: TransProperties.cpp Transforms.cpp Transforms.h
Argyrios Kyrtzidis
akyrtzi at gmail.com
Sun Nov 6 10:57:57 PST 2011
Author: akirtzidis
Date: Sun Nov 6 12:57:57 2011
New Revision: 143882
URL: http://llvm.org/viewvc/llvm-project?rev=143882&view=rev
Log:
[arcmt] Refactor PropertiesRewriter to use MigrationContext.
Modified:
cfe/trunk/lib/ARCMigrate/TransProperties.cpp
cfe/trunk/lib/ARCMigrate/Transforms.cpp
cfe/trunk/lib/ARCMigrate/Transforms.h
Modified: cfe/trunk/lib/ARCMigrate/TransProperties.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/TransProperties.cpp?rev=143882&r1=143881&r2=143882&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/TransProperties.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/TransProperties.cpp Sun Nov 6 12:57:57 2011
@@ -526,6 +526,8 @@
} // anonymous namespace
-void trans::rewriteProperties(MigrationPass &pass) {
- ImplementationChecker(pass).TraverseDecl(pass.Ctx.getTranslationUnitDecl());
+void PropertyRewriteTraverser::traverseObjCImplementation(
+ ObjCImplementationContext &ImplCtx) {
+ PropertiesRewriter(ImplCtx.getMigrationContext().getPass())
+ .doTransform(ImplCtx.getImplementationDecl());
}
Modified: cfe/trunk/lib/ARCMigrate/Transforms.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/Transforms.cpp?rev=143882&r1=143881&r2=143882&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/Transforms.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/Transforms.cpp Sun Nov 6 12:57:57 2011
@@ -302,6 +302,16 @@
public:
ASTTransform(MigrationContext &MigrateCtx) : MigrateCtx(MigrateCtx) { }
+ bool TraverseObjCImplementationDecl(ObjCImplementationDecl *D) {
+ ObjCImplementationContext ImplCtx(MigrateCtx, D);
+ for (MigrationContext::traverser_iterator
+ I = MigrateCtx.traversers_begin(),
+ E = MigrateCtx.traversers_end(); I != E; ++I)
+ (*I)->traverseObjCImplementation(ImplCtx);
+
+ return true;
+ }
+
bool TraverseStmt(Stmt *rootS) {
if (!rootS)
return true;
@@ -358,13 +368,13 @@
if (pass.isGCMigration()) {
MigrateCtx.addTraverser(new GCCollectableCallsTraverser);
}
+ MigrateCtx.addTraverser(new PropertyRewriteTraverser());
MigrateCtx.traverse(pass.Ctx.getTranslationUnitDecl());
}
static void independentTransforms(MigrationPass &pass) {
rewriteAutoreleasePool(pass);
- rewriteProperties(pass);
removeRetainReleaseDeallocFinalize(pass);
rewriteUnusedInitDelegate(pass);
removeZeroOutPropsInDeallocFinalize(pass);
Modified: cfe/trunk/lib/ARCMigrate/Transforms.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/Transforms.h?rev=143882&r1=143881&r2=143882&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/Transforms.h (original)
+++ cfe/trunk/lib/ARCMigrate/Transforms.h Sun Nov 6 12:57:57 2011
@@ -37,7 +37,6 @@
void makeAssignARCSafe(MigrationPass &pass);
void removeRetainReleaseDeallocFinalize(MigrationPass &pass);
void removeZeroOutPropsInDeallocFinalize(MigrationPass &pass);
-void rewriteProperties(MigrationPass &pass);
void rewriteBlockObjCVariable(MigrationPass &pass);
void rewriteUnusedInitDelegate(MigrationPass &pass);
void checkAPIUses(MigrationPass &pass);
@@ -58,10 +57,25 @@
Stmt *getTopStmt() { return TopStmt; }
};
+class ObjCImplementationContext {
+ MigrationContext &MigrateCtx;
+ ObjCImplementationDecl *ImpD;
+
+public:
+ ObjCImplementationContext(MigrationContext &MigrateCtx,
+ ObjCImplementationDecl *D)
+ : MigrateCtx(MigrateCtx), ImpD(D) {}
+
+ MigrationContext &getMigrationContext() { return MigrateCtx; }
+ ObjCImplementationDecl *getImplementationDecl() { return ImpD; }
+};
+
class ASTTraverser {
public:
virtual ~ASTTraverser();
+ virtual void traverseTU(MigrationContext &MigrateCtx) { }
virtual void traverseBody(BodyContext &BodyCtx) { }
+ virtual void traverseObjCImplementation(ObjCImplementationContext &ImplCtx) {}
};
class MigrationContext {
@@ -87,6 +101,11 @@
void traverse(TranslationUnitDecl *TU);
};
+class PropertyRewriteTraverser : public ASTTraverser {
+public:
+ virtual void traverseObjCImplementation(ObjCImplementationContext &ImplCtx);
+};
+
// GC transformations
class GCCollectableCallsTraverser : public ASTTraverser {
More information about the cfe-commits
mailing list