]> granicus.if.org Git - clang/commitdiff
Fix rewriting for forward class declaration.
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 11 Jan 2010 22:48:40 +0000 (22:48 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 11 Jan 2010 22:48:40 +0000 (22:48 +0000)
(fixes radar 6969189).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93201 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/RewriteObjC.cpp
test/Rewriter/rewrite-forward-class.m [new file with mode: 0644]

index 28f79aa10adfcbcc641312d8b319dd75b78d7cae..e8bb18665b5b9678ae4eaa737ec9693c3f400cb4 100644 (file)
@@ -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 (file)
index 0000000..5a50f53
--- /dev/null
@@ -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;
+