forked from OSchip/llvm-project
[arcmt] Fully migrate ObjC++ classes, rdar://9660007.
llvm-svn: 133763
This commit is contained in:
parent
795550691e
commit
0b2bd862ff
|
@ -69,8 +69,8 @@ namespace {
|
|||
class AutoreleasePoolRewriter
|
||||
: public RecursiveASTVisitor<AutoreleasePoolRewriter> {
|
||||
public:
|
||||
AutoreleasePoolRewriter(Decl *D, MigrationPass &pass)
|
||||
: Dcl(D), Body(0), Pass(pass) {
|
||||
AutoreleasePoolRewriter(MigrationPass &pass)
|
||||
: Body(0), Pass(pass) {
|
||||
PoolII = &pass.Ctx.Idents.get("NSAutoreleasePool");
|
||||
DrainSel = pass.Ctx.Selectors.getNullarySelector(
|
||||
&pass.Ctx.Idents.get("drain"));
|
||||
|
@ -411,7 +411,6 @@ private:
|
|||
return S;
|
||||
}
|
||||
|
||||
Decl *Dcl;
|
||||
Stmt *Body;
|
||||
MigrationPass &Pass;
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ namespace {
|
|||
|
||||
class RetainReleaseDeallocRemover :
|
||||
public RecursiveASTVisitor<RetainReleaseDeallocRemover> {
|
||||
Decl *Dcl;
|
||||
Stmt *Body;
|
||||
MigrationPass &Pass;
|
||||
|
||||
|
@ -39,8 +38,8 @@ class RetainReleaseDeallocRemover :
|
|||
llvm::OwningPtr<ParentMap> StmtMap;
|
||||
|
||||
public:
|
||||
RetainReleaseDeallocRemover(Decl *D, MigrationPass &pass)
|
||||
: Dcl(D), Body(0), Pass(pass) { }
|
||||
RetainReleaseDeallocRemover(MigrationPass &pass)
|
||||
: Body(0), Pass(pass) { }
|
||||
|
||||
void transformBody(Stmt *body) {
|
||||
Body = body;
|
||||
|
|
|
@ -32,15 +32,14 @@ using llvm::StringRef;
|
|||
namespace {
|
||||
|
||||
class UnusedInitRewriter : public RecursiveASTVisitor<UnusedInitRewriter> {
|
||||
Decl *Dcl;
|
||||
Stmt *Body;
|
||||
MigrationPass &Pass;
|
||||
|
||||
ExprSet Removables;
|
||||
|
||||
public:
|
||||
UnusedInitRewriter(Decl *D, MigrationPass &pass)
|
||||
: Dcl(D), Body(0), Pass(pass) { }
|
||||
UnusedInitRewriter(MigrationPass &pass)
|
||||
: Body(0), Pass(pass) { }
|
||||
|
||||
void transformBody(Stmt *body) {
|
||||
Body = body;
|
||||
|
|
|
@ -59,25 +59,8 @@ class BodyTransform : public RecursiveASTVisitor<BodyTransform<BODY_TRANS> > {
|
|||
public:
|
||||
BodyTransform(MigrationPass &pass) : Pass(pass) { }
|
||||
|
||||
void handleBody(Decl *D) {
|
||||
Stmt *body = D->getBody();
|
||||
if (body) {
|
||||
BODY_TRANS(D, Pass).transformBody(body);
|
||||
}
|
||||
}
|
||||
|
||||
bool TraverseBlockDecl(BlockDecl *D) {
|
||||
handleBody(D);
|
||||
return true;
|
||||
}
|
||||
bool TraverseObjCMethodDecl(ObjCMethodDecl *D) {
|
||||
if (D->isThisDeclarationADefinition())
|
||||
handleBody(D);
|
||||
return true;
|
||||
}
|
||||
bool TraverseFunctionDecl(FunctionDecl *D) {
|
||||
if (D->isThisDeclarationADefinition())
|
||||
handleBody(D);
|
||||
bool TraverseStmt(Stmt *rootS) {
|
||||
BODY_TRANS(Pass).transformBody(rootS);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c++ %s.result
|
||||
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -x objective-c++ %s > %t
|
||||
// RUN: diff %t %s.result
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
@interface NSString : NSObject
|
||||
+(id)string;
|
||||
@end
|
||||
|
||||
struct foo {
|
||||
NSString *s;
|
||||
foo(NSString *s): s([s retain]){
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
[[NSString string] autorelease];
|
||||
[pool drain];
|
||||
}
|
||||
~foo(){ [s release]; }
|
||||
private:
|
||||
foo(foo const &);
|
||||
foo &operator=(foo const &);
|
||||
};
|
||||
|
||||
int main(){
|
||||
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
||||
|
||||
foo f([[NSString string] autorelease]);
|
||||
|
||||
[pool drain];
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -fobjc-arc -x objective-c++ %s.result
|
||||
// RUN: arcmt-test --args -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fsyntax-only -x objective-c++ %s > %t
|
||||
// RUN: diff %t %s.result
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
@interface NSString : NSObject
|
||||
+(id)string;
|
||||
@end
|
||||
|
||||
struct foo {
|
||||
NSString *s;
|
||||
foo(NSString *s): s(s){
|
||||
@autoreleasepool {
|
||||
[NSString string];
|
||||
}
|
||||
}
|
||||
~foo(){ s; }
|
||||
private:
|
||||
foo(foo const &);
|
||||
foo &operator=(foo const &);
|
||||
};
|
||||
|
||||
int main(){
|
||||
@autoreleasepool {
|
||||
|
||||
foo f([NSString string]);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue