[cfe-commits] r43543 - in /cfe/trunk: Driver/RewriteTest.cpp Lex/Preprocessor.cpp clang.xcodeproj/project.pbxproj

Steve Naroff snaroff at apple.com
Tue Oct 30 21:38:37 PDT 2007


Author: snaroff
Date: Tue Oct 30 23:38:33 2007
New Revision: 43543

URL: http://llvm.org/viewvc/llvm-project?rev=43543&view=rev
Log:

Add some plumbing to help cope with rewriting "id<p>", "Class<p>*".

Modified:
    cfe/trunk/Driver/RewriteTest.cpp
    cfe/trunk/Lex/Preprocessor.cpp
    cfe/trunk/clang.xcodeproj/project.pbxproj

Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=43543&r1=43542&r2=43543&view=diff

==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Tue Oct 30 23:38:33 2007
@@ -64,6 +64,8 @@
     void RewriteProtocolDecl(ObjcProtocolDecl *Dcl);
     void RewriteMethods(int nMethods, ObjcMethodDecl **Methods);
     void RewriteFunctionDecl(FunctionDecl *FD);
+    bool functionReferencesAnyObjcQualifiedInterfaceTypes(
+        const FunctionTypeProto *proto);
     
     // Expression Rewriting.
     Stmt *RewriteFunctionBody(Stmt *S);
@@ -402,12 +404,41 @@
   return new CallExpr(ICE, args, nargs, FT->getResultType(), SourceLocation());
 }
 
+bool RewriteTest::functionReferencesAnyObjcQualifiedInterfaceTypes(
+  const FunctionTypeProto *proto) {
+  const PointerType *pType = proto->getResultType()->getAsPointerType();
+  if (pType) {
+    Type *pointeeType = pType->getPointeeType().getTypePtr();
+    if (isa<ObjcQualifiedInterfaceType>(pointeeType))
+      return true; // we have "Class <Protocol> *".
+  }
+  // Now check arguments.
+  for (unsigned i = 0; i < proto->getNumArgs(); i++) {
+    pType = proto->getArgType(i)->getAsPointerType();
+    if (pType) {
+      Type *pointeeType = pType->getPointeeType().getTypePtr();
+      if (isa<ObjcQualifiedInterfaceType>(pointeeType))
+        return true;
+    }
+  }
+  // FIXME: we don't currently represent "id <Protocol>" in the type system.
+  return false;
+}
+
 void RewriteTest::RewriteFunctionDecl(FunctionDecl *FD) {
   // declared in <objc/objc.h>
-  if (strcmp(FD->getName(), "sel_getUid") == 0)
+  if (strcmp(FD->getName(), "sel_getUid") == 0) {
     SelGetUidFunctionDecl = FD;
-    
-  // FIXME: Check if any types are isa<ObjcQualifiedInterfaceType> (yuck).
+    return;
+  }
+  // Check for ObjC 'id' and class types that have been adorned with protocol
+  // information (id<p>, C<p>*). The protocol references need to be rewritten!
+  const FunctionType *funcType = FD->getType()->getAsFunctionType();
+  assert(funcType && "missing function type");
+  const FunctionTypeProto *proto = dyn_cast<FunctionTypeProto>(funcType);
+  if (proto && functionReferencesAnyObjcQualifiedInterfaceTypes(proto)) {
+    // FIXME: Rewrite function decl...
+  }
 }
 
 // SynthMsgSendFunctionDecl - id objc_msgSend(id self, SEL op, ...);

Modified: cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/Preprocessor.cpp?rev=43543&r1=43542&r2=43543&view=diff

==============================================================================
--- cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/Lex/Preprocessor.cpp Tue Oct 30 23:38:33 2007
@@ -369,6 +369,7 @@
     DefineBuiltinMacro(Buf, "__OBJC__=1");
   if (PP.getLangOptions().ObjC2)
     DefineBuiltinMacro(Buf, "__OBJC2__=1");
+
   if (PP.getLangOptions().ObjC1) {
     const char *ObjcType;
     // Predefine all the ObjC goodies (traditionally declared in <objc/objc.h>).
@@ -396,7 +397,6 @@
     ObjcType = "extern SEL sel_getUid(const char *str);\n";
     Buf.insert(Buf.end(), ObjcType, ObjcType+strlen(ObjcType));
   }
-
   // Add __builtin_va_list typedef.
   {
     const char *VAList = PP.getTargetInfo().getVAListDeclaration();

Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=43543&r1=43542&r2=43543&view=diff

==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Tue Oct 30 23:38:33 2007
@@ -756,7 +756,6 @@
 		08FB7793FE84155DC02AAC07 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
-			compatibilityVersion = "Xcode 2.4";
 			hasScannedForEncodings = 1;
 			mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
 			projectDirPath = "";





More information about the cfe-commits mailing list