From aff228dfc74d664512f682a1869a47286f09b57a Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Wed, 31 Oct 2007 17:29:28 +0000 Subject: [PATCH] Rewriteing of ivars changed to just copy directly from the source. llvm-svn: 43560 --- clang/Driver/RewriteTest.cpp | 43 ++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/clang/Driver/RewriteTest.cpp b/clang/Driver/RewriteTest.cpp index 6a5bb0fc3a4b..d3bbb1b48a8f 100644 --- a/clang/Driver/RewriteTest.cpp +++ b/clang/Driver/RewriteTest.cpp @@ -550,23 +550,48 @@ void RewriteTest::SynthesizeObjcInternalStruct(ObjcInterfaceDecl *CDecl, Result += "\nstruct _interface_"; Result += CDecl->getName(); - Result += " {\n"; if (RCDecl && ObjcSynthesizedStructs.count(RCDecl)) { + Result += " {\n"; Result += "\tstruct _interface_"; Result += RCDecl->getName(); Result += " _"; Result += RCDecl->getName(); Result += ";\n"; } - - ObjcIvarDecl **Ivars = CDecl->getIntfDeclIvars(); - for (int i = 0; i < NumIvars; i++) { - Result += "\t"; - std::string Name = Ivars[i]->getName(); - Ivars[i]->getType().getAsStringInternal(Name); - Result += Name; - Result += ";\n"; + else + Result += " {"; + if (NumIvars > 0) { + SourceLocation LocStart = CDecl->getLocStart(); + SourceLocation LocEnd = CDecl->getLocEnd(); + + const char *startBuf = SM->getCharacterData(LocStart); + const char *endBuf = SM->getCharacterData(LocEnd); + startBuf = strchr(startBuf, '{'); + assert((startBuf && endBuf) + && "SynthesizeObjcInternalStruct - malformed @interface"); + startBuf++; // past '{' + while (startBuf < endBuf) { + if (*startBuf == '@') { + startBuf = strchr(startBuf, 'p'); + // FIXME: presence of @public, etc. inside comment results in + // this transformation as well, which is still correct c-code. + if (!strncmp(startBuf, "public", strlen("public"))) { + startBuf += strlen("public"); + Result += "/* @public */"; + } + else if (!strncmp(startBuf, "private", strlen("private"))) { + startBuf += strlen("private"); + Result += "/* @private */"; + } + else if (!strncmp(startBuf, "protected", strlen("protected"))) { + startBuf += strlen("protected"); + Result += "/* @protected */"; + } + } + Result += *startBuf++; + } } + Result += "};\n"; // Mark this struct as having been generated. if (!ObjcSynthesizedStructs.insert(CDecl))