[cfe-commits] r43093 - /cfe/trunk/Driver/RewriteTest.cpp

Chris Lattner sabre at nondot.org
Wed Oct 17 14:28:00 PDT 2007


Author: lattner
Date: Wed Oct 17 16:28:00 2007
New Revision: 43093

URL: http://llvm.org/viewvc/llvm-project?rev=43093&view=rev
Log:
Add rewriter support for @encode expressions. For example,
we currently turn:

    c = @encode(char *)[2] + 4;

into:

    c = "foo"[2] + 4;

Right now the foo string is hard coded, but you can imagine a world
where it wouldn't be :)



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=43093&r1=43092&r2=43093&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Wed Oct 17 16:28:00 2007
@@ -104,18 +104,18 @@
   // Otherwise, just rewrite all children.
   for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
        CI != E; ++CI)
-    RewriteFunctionBody(*CI);
+    if (*CI)
+      RewriteFunctionBody(*CI);
 }
 
 void RewriteTest::RewriteAtEncode(ObjCEncodeExpr *Exp) {
-#if 0
   int Size = Rewrite.getRangeSize(Exp->getSourceRange());
   if (Size == -1) {
     printf("BLAH!");
+    return;
   }
   
-  Rewrite.RemoveText(Exp->getAtLoc(), Size);
-#endif
+  Rewrite.ReplaceText(Exp->getAtLoc(), Size, "\"foo\"", 5);
 }
 
 





More information about the cfe-commits mailing list