[cfe-commits] r104512 - in /cfe/trunk: lib/Frontend/RewriteObjC.cpp test/Rewriter/rewrite-no-nextline.mm

Fariborz Jahanian fjahanian at apple.com
Mon May 24 10:22:38 PDT 2010


Author: fjahanian
Date: Mon May 24 12:22:38 2010
New Revision: 104512

URL: http://llvm.org/viewvc/llvm-project?rev=104512&view=rev
Log:
Fix an objective-c rewriter bug when pre-processed file's 
class declaration's @end is not followed by a new-line.
(radar 7946975).

Added:
    cfe/trunk/test/Rewriter/rewrite-no-nextline.mm
Modified:
    cfe/trunk/lib/Frontend/RewriteObjC.cpp

Modified: cfe/trunk/lib/Frontend/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/RewriteObjC.cpp?rev=104512&r1=104511&r2=104512&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/RewriteObjC.cpp (original)
+++ cfe/trunk/lib/Frontend/RewriteObjC.cpp Mon May 24 12:22:38 2010
@@ -971,7 +971,8 @@
     RewriteMethodDeclaration(*I);
 
   // Lastly, comment out the @end.
-  ReplaceText(CatDecl->getAtEndRange().getBegin(), 0, "// ");
+  ReplaceText(CatDecl->getAtEndRange().getBegin(), 
+              strlen("@end"), "/* @end */");
 }
 
 void RewriteObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) {
@@ -991,7 +992,7 @@
 
   // Lastly, comment out the @end.
   SourceLocation LocEnd = PDecl->getAtEndRange().getBegin();
-  ReplaceText(LocEnd, 0, "// ");
+  ReplaceText(LocEnd, strlen("@end"), "/* @end */");
 
   // Must comment out @optional/@required
   const char *startBuf = SM->getCharacterData(LocStart);
@@ -1220,7 +1221,8 @@
     RewriteMethodDeclaration(*I);
 
   // Lastly, comment out the @end.
-  ReplaceText(ClassDecl->getAtEndRange().getBegin(), 0, "// ");
+  ReplaceText(ClassDecl->getAtEndRange().getBegin(), strlen("@end"), 
+              "/* @end */");
 }
 
 Stmt *RewriteObjC::RewritePropertySetter(BinaryOperator *BinOp, Expr *newStmt,

Added: cfe/trunk/test/Rewriter/rewrite-no-nextline.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/rewrite-no-nextline.mm?rev=104512&view=auto
==============================================================================
--- cfe/trunk/test/Rewriter/rewrite-no-nextline.mm (added)
+++ cfe/trunk/test/Rewriter/rewrite-no-nextline.mm Mon May 24 12:22:38 2010
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// radar 7946975
+
+ at interface RootObject {
+}
+ at end void doStuff();
+int main(int argc, char *argv[]) {
+    return 0;
+}





More information about the cfe-commits mailing list