summaryrefslogtreecommitdiffstats
path: root/clang/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
commitdc917b9e078df90e3630ceb9f802b507bb54f52d (patch)
treee6af09bfe3b71229c15f449dd6efa746408d9980 /clang/Driver/RewriteTest.cpp
parent730d088be125c67fba9b73f325a2f86272798af1 (diff)
downloadbcm5719-llvm-dc917b9e078df90e3630ceb9f802b507bb54f52d.tar.gz
bcm5719-llvm-dc917b9e078df90e3630ceb9f802b507bb54f52d.zip
Patch to start rewriting of ObjC2's foreach statement (work in progress).
llvm-svn: 45721
Diffstat (limited to 'clang/Driver/RewriteTest.cpp')
-rw-r--r--clang/Driver/RewriteTest.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/clang/Driver/RewriteTest.cpp b/clang/Driver/RewriteTest.cpp
index 93c9838a910..2b743f91354 100644
--- a/clang/Driver/RewriteTest.cpp
+++ b/clang/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();
OpenPOWER on IntegriCloud