aboutsummaryrefslogtreecommitdiff
path: root/Driver/RewriteTest.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2008-01-07 21:40:22 +0000
committerFariborz Jahanian <fjahanian@apple.com>2008-01-07 21:40:22 +0000
commit10d24f062ee8c83823199191ccdba452c7f9ac24 (patch)
tree87bcb01943e0685bae09a72ddf0f74c8275c0d5e /Driver/RewriteTest.cpp
parentc5ae5cf88ff108f7a325c7b686f78c02517a44e5 (diff)
Patch to start rewriting of ObjC2's foreach statement (work in progress).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45721 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/RewriteTest.cpp')
-rw-r--r--Driver/RewriteTest.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp
index 93c9838a91..2b743f9135 100644
--- a/Driver/RewriteTest.cpp
+++ b/Driver/RewriteTest.cpp
@@ -164,6 +164,7 @@ namespace {
Stmt *RewriteObjCCatchStmt(ObjCAtCatchStmt *S);
Stmt *RewriteObjCFinallyStmt(ObjCAtFinallyStmt *S);
Stmt *RewriteObjCThrowStmt(ObjCAtThrowStmt *S);
+ Stmt *RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S);
CallExpr *SynthesizeCallToFunctionDecl(FunctionDecl *FD,
Expr **args, unsigned nargs);
void SynthMsgSendFunctionDecl();
@@ -737,6 +738,11 @@ Stmt *RewriteTest::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
if (ObjCProtocolExpr *ProtocolExp = dyn_cast<ObjCProtocolExpr>(S))
return RewriteObjCProtocolExpr(ProtocolExp);
+
+ if (ObjCForCollectionStmt *StmtForCollection =
+ dyn_cast<ObjCForCollectionStmt>(S))
+ return RewriteObjCForCollectionStmt(StmtForCollection);
+
#if 0
if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(S)) {
CastExpr *Replacement = new CastExpr(ICE->getType(), ICE->getSubExpr(), SourceLocation());
@@ -754,7 +760,40 @@ Stmt *RewriteTest::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
// Return this stmt unmodified.
return S;
}
+
+
+/// RewriteObjCTryStmt - Rewriter for ObjC2's feareach statement.
+/// It rewrites:
+/// for ( type elem in collection) { stmts; }
+/// Into:
+/// {
+/// type elem;
+/// __objcFastEnumerationState enumState = { 0 };
+/// id items[16];
+/// unsigned long limit = [collection countByEnumeratingWithState:&enumState
+/// objects:items count:16];
+/// if (limit) {
+/// unsigned long startMutations = *enumState.mutationsPtr;
+/// do {
+/// unsigned long counter = 0;
+/// do {
+/// if (startMutations != *enumState.mutationsPtr)
+/// objc_enumerationMutation(collection);
+/// elem = enumState.itemsPtr[counter++];
+/// stmts;
+/// } while (counter < limit);
+/// } while (limit = [collection countByEnumeratingWithState:&enumState
+/// objects:items count:16]);
+/// }
+/// else
+/// elem = nil;
+/// }
+///
+Stmt *RewriteTest::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S) {
+ return S;
+}
+
Stmt *RewriteTest::RewriteObjCTryStmt(ObjCAtTryStmt *S) {
// Get the start location and compute the semi location.
SourceLocation startLoc = S->getLocStart();