[llvm-branch-commits] [cfe-branch] r86839 - /cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp

Steve Naroff snaroff at apple.com
Wed Nov 11 06:30:20 PST 2009


Author: snaroff
Date: Wed Nov 11 08:30:20 2009
New Revision: 86839

URL: http://llvm.org/viewvc/llvm-project?rev=86839&view=rev
Log:
Rollback changes for <rdar://problem/6675450>.

Modified:
    cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp

Modified: cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp?rev=86839&r1=86838&r2=86839&view=diff

==============================================================================
--- cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp (original)
+++ cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp Wed Nov 11 08:30:20 2009
@@ -687,7 +687,7 @@
 static std::string getIvarAccessString(ObjCInterfaceDecl *ClassDecl,
                                        ObjCIvarDecl *OID) {
   std::string S;
-  S = "((p";
+  S = "((struct ";
   S += ClassDecl->getIdentifier()->getName();
   S += "_IMPL *)self)->";
   S += OID->getNameAsCString();
@@ -1161,23 +1161,14 @@
       iFaceDecl->getDecl()->lookupInstanceVariable(D->getIdentifier(), clsDeclared);
       assert(clsDeclared && "RewriteObjCIvarRefExpr(): Can't find class");
       
+      // Synthesize an explicit cast to gain access to the ivar.
       std::string RecName = clsDeclared->getIdentifier()->getName();
       RecName += "_IMPL";
       IdentifierInfo *II = &Context->Idents.get(RecName.c_str());
       RecordDecl *RD = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
                                           SourceLocation(), II);
       assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
-      QualType RDT = Context->getTagDeclType(RD);
-      
-      // Synthesize an explicit cast to gain access to the ivar.
-      RecName = "p";
-      RecName += clsDeclared->getIdentifier()->getName();
-      RecName += "_IMPL";
-      II = &Context->Idents.get(RecName.c_str());
-      TypedefDecl *TD = TypedefDecl::Create(*Context, TUDecl,
-                                          SourceLocation(), II, RDT);
-      assert(TD && "RewriteObjCIvarRefExpr(): Can't find TypedefDecl");
-      QualType castT = Context->getTypedefType(TD);
+      QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
       CastExpr *castExpr = new CStyleCastExpr(castT, IV->getBase(), castT,
                                                  SourceLocation(), SourceLocation());
       // Don't forget the parens to enforce the proper binding.
@@ -1219,17 +1210,7 @@
       RecordDecl *RD = RecordDecl::Create(*Context, TagDecl::TK_struct, TUDecl,
                                           SourceLocation(), II);
       assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
-      QualType RDT = Context->getTagDeclType(RD);
-      
-      // Synthesize an explicit cast to gain access to the ivar.
-      RecName = "p";
-      RecName += clsDeclared->getIdentifier()->getName();
-      RecName += "_IMPL";
-      II = &Context->Idents.get(RecName.c_str());
-      TypedefDecl *TD = TypedefDecl::Create(*Context, TUDecl,
-                                          SourceLocation(), II, RDT);
-      assert(TD && "RewriteObjCIvarRefExpr(): Can't find TypedefDecl");
-      QualType castT = Context->getTypedefType(TD);
+      QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
       CastExpr *castExpr = new CStyleCastExpr(castT, IV->getBase(), castT,
                                                  SourceLocation(), SourceLocation());
       // Don't forget the parens to enforce the proper binding.
@@ -2791,7 +2772,10 @@
   
   // FIXME: This has potential of causing problem. If 
   // SynthesizeObjCInternalStruct is ever called recursively.
-  Result += "\ntypedef struct ";
+  Result += "\nstruct ";
+  Result += CDecl->getNameAsString();
+  if (LangOpts.Microsoft)
+    Result += "_IMPL";
 
   if (NumIvars > 0) {
     const char *cursor = strchr(startBuf, '{');
@@ -2830,7 +2814,7 @@
       ReplaceText(LocStart, cursor-startBuf, Result.c_str(), Result.size());
     }
     if (RCDecl && ObjCSynthesizedStructs.count(RCDecl)) {
-      Result = "\n    ";
+      Result = "\n    struct ";
       Result += RCDecl->getNameAsString();
       Result += "_IMPL ";
       Result += RCDecl->getNameAsString();
@@ -2875,35 +2859,15 @@
       }
       cursor++;
     }
-    // Don't forget to add the typedef name and a ';'!!
-    Result = " ";
-    Result += CDecl->getNameAsString();
-    Result += "_IMPL;";
-    // Now generate a typedef for the pointer to the "IMPL". For some reason,
-    // The Microsoft compiler want to see this in a separate declaration.
-    Result += "\ntypedef ";
-    Result += CDecl->getNameAsString();
-    Result += "_IMPL *p";
-    Result += CDecl->getNameAsString();
-    Result += "_IMPL;";
-    InsertText(LocEnd.getFileLocWithOffset(1), Result.c_str(), Result.size());
+    // Don't forget to add a ';'!!
+    InsertText(LocEnd.getFileLocWithOffset(1), ";", 1);
   } else { // we don't have any instance variables - insert super struct.
     endBuf += Lexer::MeasureTokenLength(LocEnd, *SM);
-    Result += "{\n    ";
+    Result += " {\n    struct ";
     Result += RCDecl->getNameAsString();
     Result += "_IMPL ";
     Result += RCDecl->getNameAsString();
-    Result += "_IVARS;\n} ";
-    // Don't forget to add the typedef name and a ';'!!
-    Result += CDecl->getNameAsString();
-    Result += "_IMPL;";
-    // Now generate a typedef for the pointer to the "IMPL". For some reason,
-    // The Microsoft compiler want to see this in a separate declaration.
-    Result += "\ntypedef ";
-    Result += CDecl->getNameAsString();
-    Result += "_IMPL *p";
-    Result += CDecl->getNameAsString();
-    Result += "_IMPL;";
+    Result += "_IVARS;\n};\n";
     ReplaceText(LocStart, endBuf-startBuf, Result.c_str(), Result.size());
   }
   // Mark this struct as having been generated.
@@ -3273,7 +3237,7 @@
     // place all bitfields at offset 0.
     Result += "0";
   } else {
-    Result += "__OFFSETOFIVAR__(";
+    Result += "__OFFSETOFIVAR__(struct ";
     Result += IDecl->getNameAsString();
     if (LangOpts.Microsoft)
       Result += "_IMPL";
@@ -3488,7 +3452,7 @@
     Result += ",0";
   else {
     // class has size. Must synthesize its size.
-    Result += ",sizeof(";
+    Result += ",sizeof(struct ";
     Result += CDecl->getNameAsString();
     if (LangOpts.Microsoft)
       Result += "_IMPL";





More information about the llvm-branch-commits mailing list