]> granicus.if.org Git - clang/commitdiff
Predefine all the ObjC goodies from <objc/objc.h>. Removed all the ObjC goodies from...
authorSteve Naroff <snaroff@apple.com>
Wed, 17 Oct 2007 17:53:50 +0000 (17:53 +0000)
committerSteve Naroff <snaroff@apple.com>
Wed, 17 Oct 2007 17:53:50 +0000 (17:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43077 91177308-0d34-0410-b5e6-96231b3b80d8

Lex/Preprocessor.cpp
test/Sema/argument-checking.m
test/Sema/id_not_builtin.m
test/Sema/method-not-defined.m
test/Sema/selector-1.m
test/Sema/selector-overload.m

index 78e4496a5d55946599b7998f3286a85b2126c497..c1f14a9b9bc12b37b185c5d918fbf162d4cad8a6 100644 (file)
@@ -371,9 +371,27 @@ static void InitializePredefinedMacros(Preprocessor &PP,
     DefineBuiltinMacro(Buf, "__OBJC2__=1");
 
   if (PP.getLangOptions().ObjC1) {
-    // FIXME: make this the right thing.
-    const char *IDTypedef = "/*typedef int id;*/\n";
-    Buf.insert(Buf.end(), IDTypedef, IDTypedef+strlen(IDTypedef));
+    // Predefine all the ObjC goodies (traditionally declared in <objc/objc.h>).
+    // We define the following header guard for source compatibility. It has
+    // the effect of ignoring any explicit inclusion of <objc/objc.h>:-)
+    DefineBuiltinMacro(Buf, "_OBJC_OBJC_H_=1");
+    DefineBuiltinMacro(Buf, "OBJC_EXPORT=extern");
+    DefineBuiltinMacro(Buf, "OBJC_IMPORT=extern");
+    const char *ObjcType;
+    ObjcType = "typedef struct objc_class *Class;\n";
+    Buf.insert(Buf.end(), ObjcType, ObjcType+strlen(ObjcType));
+    ObjcType = "typedef struct objc_object { Class isa; } *id;\n";
+    Buf.insert(Buf.end(), ObjcType, ObjcType+strlen(ObjcType));
+    ObjcType = "typedef struct objc_selector *SEL;\n";
+    Buf.insert(Buf.end(), ObjcType, ObjcType+strlen(ObjcType));
+    ObjcType = "typedef id (*IMP)(id, SEL, ...);\n";
+    Buf.insert(Buf.end(), ObjcType, ObjcType+strlen(ObjcType));
+    ObjcType = "typedef signed char BOOL;\n";
+    Buf.insert(Buf.end(), ObjcType, ObjcType+strlen(ObjcType));
+    DefineBuiltinMacro(Buf, "YES=(BOOL)1");
+    DefineBuiltinMacro(Buf, "NO=(BOOL)0");
+    DefineBuiltinMacro(Buf, "Nil=0");
+    DefineBuiltinMacro(Buf, "nil=0");
   }
 
   // Add __builtin_va_list typedef.
index cf7eb8386b7700989d4a0a530da431d46176ff70..851a874c9359b92cbf84a7b6386770088760a86c 100644 (file)
@@ -1,7 +1,5 @@
 // RUN: clang -fsyntax-only -verify %s
 
-typedef struct objc_object *id;
-
 struct S { int a; };
 
 extern int charStarFunc(char *);
index 519e6bab8fa4c7b0c8b94161581407a20a7ffac6..42d13fd4420ee4e37ce3bd63ce42989d55ec456b 100644 (file)
@@ -1,9 +1,10 @@
 // RUN: clang %s -fsyntax-only -verify
 
-id obj; // expected-error{{expected '=', ',', ';', 'asm', or '__attribute__' after declarator}}
+// id is now builtin. There should be no errors. Should probably remove this file.
+id obj; 
 
 @interface Foo
 
-- defaultToId; // expected-error{{cannot find definition of 'id'}}
+- defaultToId; 
 
 @end
index adb8a67fc80ed926ce278aa7be1af0c746cafa50..62a8be72e7dca6492d0c34062ecc828179dd83bb 100644 (file)
@@ -1,6 +1,5 @@
 // RUN: clang -fsyntax-only -verify %s
 
-typedef struct objc_object *id;
 @interface Foo
 @end
 
index 59717c30793b61a82d976ef2b67fdd34f2eaadec..476568f6caa40b7b71a9fcac8812a6443956a1b5 100644 (file)
@@ -1,7 +1,5 @@
 // RUN: clang -verify %s 
 
-typedef struct objc_selector *SEL;
-
 int main() {
  SEL s = @selector(retain);
  SEL s1 = @selector(meth1:);
index e84d21432c6f0f2a26eb018659e0ba41d45ac06b..7bd25444c7e9120bf4abd7ce2884dc00b23837b4 100644 (file)
@@ -1,6 +1,5 @@
 // RUN: clang %s -fsyntax-only
 
-typedef struct objc_object *id;
 @interface NSObject
 + alloc;
 - init;