]> granicus.if.org Git - clang/commitdiff
Checking in some code that is still under construction.
authorSteve Naroff <snaroff@apple.com>
Wed, 31 Oct 2007 16:03:04 +0000 (16:03 +0000)
committerSteve Naroff <snaroff@apple.com>
Wed, 31 Oct 2007 16:03:04 +0000 (16:03 +0000)
I need to (finally) change the way Class/id/SEL/IMP are built-in...the current approach of doing it in the preprocessor is "broken". The other problem is Sema::GetObjcIdType/GetObjcSelType/GetObjcClassType, the hooks that initialize ASTContext lazily. These built-in types need to be done up front...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43557 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/RewriteTest.cpp
Lex/Preprocessor.cpp

index 788b522612801da1f1de8d2c699412a729c328f0..6a5bb0fc3a4b74994be9ae34d89ba8ab5c40539f 100644 (file)
@@ -406,22 +406,28 @@ CallExpr *RewriteTest::SynthesizeCallToFunctionDecl(
 
 bool RewriteTest::functionReferencesAnyObjcQualifiedInterfaceTypes(
   const FunctionTypeProto *proto) {
-  const PointerType *pType = proto->getResultType()->getAsPointerType();
-  if (pType) {
+  QualType resultType = proto->getResultType();
+  
+  if (resultType == Context->getObjcIdType()) {
+    // FIXME: we don't currently represent "id <Protocol>" in the type system.
+    // Implement a heuristic here (until we do).
+  } else if (const PointerType *pType = resultType->getAsPointerType()) {
     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) {
+    QualType argType = proto->getArgType(i);
+    if (argType == Context->getObjcIdType()) {
+      // FIXME: we don't currently represent "id <Protocol>" in the type system.
+      // Implement a heuristic here (until we do).
+    } else if (const PointerType *pType = argType->getAsPointerType()) {
       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;
 }
 
@@ -431,6 +437,7 @@ void RewriteTest::RewriteFunctionDecl(FunctionDecl *FD) {
     SelGetUidFunctionDecl = FD;
     return;
   }
+  return; // FIXME: remove when the code below is ready.
   // 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();
index 04b2a80f02baf323bcf828681987b48f8c52cd35..c1f4970f30d94bc2cbbd378761618618ab84ac6e 100644 (file)
@@ -369,7 +369,6 @@ static void InitializePredefinedMacros(Preprocessor &PP,
     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>).