modern objc translator: fixes a bug where a class declaration with not
any implementation in tu was not being translated.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151106 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Rewrite/RewriteModernObjC.cpp b/lib/Rewrite/RewriteModernObjC.cpp
index 6e075f2..9c95261 100644
--- a/lib/Rewrite/RewriteModernObjC.cpp
+++ b/lib/Rewrite/RewriteModernObjC.cpp
@@ -3230,16 +3230,6 @@
 /// and emits meta-data.
 
 void RewriteModernObjC::RewriteImplementations() {
-  
-  for (unsigned i = 0, e = ObjCInterfacesSeen.size(); i < e; i++) {
-    ObjCInterfaceDecl *CDecl = ObjCInterfacesSeen[i];
-    // Write struct declaration for the class matching its ivar declarations.
-    // Note that for modern abi, this is postponed until the end of TU
-    // because class extensions and the implementation might declare their own
-    // private ivars.
-    RewriteInterfaceDecl(CDecl);
-  }
-  
   int ClsDefCount = ClassImplementation.size();
   int CatDefCount = CategoryImplementation.size();
 
@@ -5022,6 +5012,15 @@
     RewriteObjCProtocolMetaData(*I, Preamble);
 
   InsertText(SM->getLocForStartOfFile(MainFileID), Preamble, false);
+  for (unsigned i = 0, e = ObjCInterfacesSeen.size(); i < e; i++) {
+    ObjCInterfaceDecl *CDecl = ObjCInterfacesSeen[i];
+    // Write struct declaration for the class matching its ivar declarations.
+    // Note that for modern abi, this is postponed until the end of TU
+    // because class extensions and the implementation might declare their own
+    // private ivars.
+    RewriteInterfaceDecl(CDecl);
+  }
+
   if (ClassImplementation.size() || CategoryImplementation.size())
     RewriteImplementations();