More support for rewriting ObjC intefaces. Still some edge cases to handle...



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43493 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp
index c76b9ee..8063574 100644
--- a/Driver/RewriteTest.cpp
+++ b/Driver/RewriteTest.cpp
@@ -264,6 +264,27 @@
 }
 
 void RewriteTest::RewriteInterfaceDecl(ObjcInterfaceDecl *ClassDecl) {
+
+  SourceLocation LocStart = ClassDecl->getLocStart();
+  SourceLocation LocEnd = ClassDecl->getLocEnd();
+
+  const char *startBuf = SM->getCharacterData(LocStart);
+  const char *endBuf = SM->getCharacterData(LocEnd);
+
+  // FIXME: need to consider empty class decls (no vars, methods)...
+  //   @interface NSConstantString : NSSimpleCString
+  //   @end
+
+  if (*endBuf != '>' && *endBuf != '}')
+    // we have an identifier - scan ahead until the end of token.
+    endBuf = strchr(endBuf, ' '); // FIXME: implement correctly.
+
+  std::string ResultStr;
+  SynthesizeObjcInternalStruct(ClassDecl, ResultStr);
+    
+  Rewrite.ReplaceText(LocStart, endBuf-startBuf+1, 
+                      ResultStr.c_str(), ResultStr.size());
+  
   int nInstanceMethods = ClassDecl->getNumInstanceMethods();
   ObjcMethodDecl **instanceMethods = ClassDecl->getInstanceMethods();