From 91fbd12d8b6e60b72883ff4c42e2a0993087f876 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Mon, 11 Jan 2010 22:48:40 +0000 Subject: [PATCH] Fix rewriting for forward class declaration. (fixes radar 6969189). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93201 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/RewriteObjC.cpp | 14 +++++++++++--- test/Rewriter/rewrite-forward-class.m | 8 ++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 test/Rewriter/rewrite-forward-class.m diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp index 28f79aa10a..e8bb18665b 100644 --- a/lib/Frontend/RewriteObjC.cpp +++ b/lib/Frontend/RewriteObjC.cpp @@ -787,9 +787,17 @@ void RewriteObjC::RewriteForwardClassDecl(ObjCClassDecl *ClassDecl) { // as the class. As a convenience, we include the original declaration // as a comment. std::string typedefString; - typedefString += "// "; - typedefString.append(startBuf, semiPtr-startBuf+1); - typedefString += "\n"; + typedefString += "// @class "; + for (ObjCClassDecl::iterator I = ClassDecl->begin(), E = ClassDecl->end(); + I != E; ++I) { + ObjCInterfaceDecl *ForwardDecl = I->getInterface(); + typedefString += ForwardDecl->getNameAsString(); + if (I+1 != E) + typedefString += ", "; + else + typedefString += ";\n"; + } + for (ObjCClassDecl::iterator I = ClassDecl->begin(), E = ClassDecl->end(); I != E; ++I) { ObjCInterfaceDecl *ForwardDecl = I->getInterface(); diff --git a/test/Rewriter/rewrite-forward-class.m b/test/Rewriter/rewrite-forward-class.m new file mode 100644 index 0000000000..5a50f53a48 --- /dev/null +++ b/test/Rewriter/rewrite-forward-class.m @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -rewrite-objc -o - %s +// rdar://6969189 + +@class XX; +@class YY, ZZ, QQ; +@class ISyncClient, SMSession, ISyncManager, ISyncSession, SMDataclassInfo, SMClientInfo, + DMCConfiguration, DMCStatusEntry; +