More support for rewriting ObjC intefaces. Still some edge cases to handle...
llvm-svn: 43493
diff --git a/clang/Driver/RewriteTest.cpp b/clang/Driver/RewriteTest.cpp
index c76b9ee..8063574 100644
--- a/clang/Driver/RewriteTest.cpp
+++ b/clang/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();