aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2010-05-24 17:22:38 +0000
committerFariborz Jahanian <fjahanian@apple.com>2010-05-24 17:22:38 +0000
commit73d1eb064350d5310f0475366cbe54d2d1da27bb (patch)
treee7e9c75bf495fcc0845d00b6b55c8971558b6d54
parent836adf6771d5170d936599dfcce21687e37e9bbf (diff)
Fix an objective-c rewriter bug when pre-processed file's
class declaration's @end is not followed by a new-line. (radar 7946975). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104512 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Frontend/RewriteObjC.cpp8
-rw-r--r--test/Rewriter/rewrite-no-nextline.mm10
2 files changed, 15 insertions, 3 deletions
diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp
index 892fc73bfc..4027b37c69 100644
--- a/lib/Frontend/RewriteObjC.cpp
+++ b/lib/Frontend/RewriteObjC.cpp
@@ -971,7 +971,8 @@ void RewriteObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) {
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 @@ void RewriteObjC::RewriteProtocolDecl(ObjCProtocolDecl *PDecl) {
// 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 @@ void RewriteObjC::RewriteInterfaceDecl(ObjCInterfaceDecl *ClassDecl) {
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,
diff --git a/test/Rewriter/rewrite-no-nextline.mm b/test/Rewriter/rewrite-no-nextline.mm
new file mode 100644
index 0000000000..0c3657c906
--- /dev/null
+++ b/test/Rewriter/rewrite-no-nextline.mm
@@ -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
+
+@interface RootObject {
+}
+@end void doStuff();
+int main(int argc, char *argv[]) {
+ return 0;
+}