[cfe-commits] r45721 - /cfe/trunk/Driver/RewriteTest.cpp
Fariborz Jahanian
fjahanian at apple.com
Mon Jan 7 13:40:22 PST 2008
Author: fjahanian
Date: Mon Jan 7 15:40:22 2008
New Revision: 45721
URL: http://llvm.org/viewvc/llvm-project?rev=45721&view=rev
Log:
Patch to start rewriting of ObjC2's foreach statement (work in progress).
Modified:
cfe/trunk/Driver/RewriteTest.cpp
Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=45721&r1=45720&r2=45721&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Mon Jan 7 15:40:22 2008
@@ -164,6 +164,7 @@
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 @@
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 @@
// 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();
More information about the cfe-commits
mailing list