diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2007-11-14 22:26:25 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2007-11-14 22:26:25 +0000 |
commit | 9567392e164128d853f0005014114d1ffc06fa86 (patch) | |
tree | 266deee67d18e49ba85b680607351e202d52c998 /Driver/RewriteTest.cpp | |
parent | 6336f8dbae5145eb7b1429a8ec424c44e668f7cb (diff) |
Patch to comment out use of protocol qualifiers when rewriting ivars.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44142 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/RewriteTest.cpp')
-rw-r--r-- | Driver/RewriteTest.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/Driver/RewriteTest.cpp b/Driver/RewriteTest.cpp index 07b66275ec..92d928cd08 100644 --- a/Driver/RewriteTest.cpp +++ b/Driver/RewriteTest.cpp @@ -70,7 +70,8 @@ namespace { "extern void objc_exception_try_exit(void *);\n" "extern struct objc_object *objc_exception_extract(void *);\n" "extern int objc_exception_match" - "(struct objc_class *, struct objc_object *, ...);\n"; + "(struct objc_class *, struct objc_object *, ...);\n" + "#include <Objc/objc.h>\n"; Rewrite.InsertText(SourceLocation::getFileLoc(mainFileID, 0), s, strlen(s)); @@ -421,11 +422,6 @@ void RewriteTest::RewriteForwardProtocolDecl(ObjcForwardProtocolDecl *PDecl) { void RewriteTest::RewriteObjcMethodDecl(ObjcMethodDecl *OMD, std::string &ResultStr) { - static bool includeObjc = false; - if (!includeObjc) { - ResultStr += "#include <Objc/objc.h>\n"; - includeObjc = true; - } ResultStr += "\nstatic "; ResultStr += OMD->getResultType().getAsString(); ResultStr += "\n"; @@ -1146,7 +1142,8 @@ void RewriteTest::SynthesizeObjcInternalStruct(ObjcInterfaceDecl *CDecl, // have no ivars (thus not synthesized) then no need to synthesize this class. if (NumIvars <= 0 && (!RCDecl || !ObjcSynthesizedStructs.count(RCDecl))) return; - + // FIXME: This has potential of causing problem. If + // SynthesizeObjcInternalStruct is ever called recursively. Result += "\nstruct "; Result += CDecl->getName(); @@ -1186,9 +1183,20 @@ void RewriteTest::SynthesizeObjcInternalStruct(ObjcInterfaceDecl *CDecl, // this transformation as well, which is still correct c-code. if (!strncmp(cursor, "public", strlen("public")) || !strncmp(cursor, "private", strlen("private")) || - !strncmp(cursor, "protected", strlen("private"))) + !strncmp(cursor, "protected", strlen("protected"))) Rewrite.InsertText(atLoc, "// ", 3); } + // FIXME: If there are cases where '<' is used in ivar declaration part + // of user code, then scan the ivar list and use needToScanForQualifiers + // for type checking. + else if (*cursor == '<') { + SourceLocation atLoc = LocStart.getFileLocWithOffset(cursor-startBuf); + Rewrite.InsertText(atLoc, "/* ", 3); + cursor = strchr(cursor, '>'); + cursor++; + atLoc = LocStart.getFileLocWithOffset(cursor-startBuf); + Rewrite.InsertText(atLoc, " */", 3); + } cursor++; } // Don't forget to add a ';'!! @@ -1799,9 +1807,6 @@ void RewriteTest::RewriteImplementations(std::string &Result) { for (int i = 0; i < CatDefCount; i++) RewriteImplementationDecl(CategoryImplementation[i]); - // TODO: This is temporary until we decide how to access objc types in a - // c program - Result += "#include <Objc/objc.h>\n"; // This is needed for use of offsetof Result += "#include <stddef.h>\n"; |