From: Steve Naroff Date: Wed, 17 Oct 2007 17:53:50 +0000 (+0000) Subject: Predefine all the ObjC goodies from . Removed all the ObjC goodies from... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b8e891be648481b68439c01eff509775214067c;p=clang Predefine all the ObjC goodies from . Removed all the ObjC goodies from the respective test files. Moving forward, it will be very nice to assume these builtin! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@43077 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Lex/Preprocessor.cpp b/Lex/Preprocessor.cpp index 78e4496a5d..c1f14a9b9b 100644 --- a/Lex/Preprocessor.cpp +++ b/Lex/Preprocessor.cpp @@ -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 ). + // We define the following header guard for source compatibility. It has + // the effect of ignoring any explicit inclusion of :-) + 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. diff --git a/test/Sema/argument-checking.m b/test/Sema/argument-checking.m index cf7eb8386b..851a874c93 100644 --- a/test/Sema/argument-checking.m +++ b/test/Sema/argument-checking.m @@ -1,7 +1,5 @@ // RUN: clang -fsyntax-only -verify %s -typedef struct objc_object *id; - struct S { int a; }; extern int charStarFunc(char *); diff --git a/test/Sema/id_not_builtin.m b/test/Sema/id_not_builtin.m index 519e6bab8f..42d13fd442 100644 --- a/test/Sema/id_not_builtin.m +++ b/test/Sema/id_not_builtin.m @@ -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 diff --git a/test/Sema/method-not-defined.m b/test/Sema/method-not-defined.m index adb8a67fc8..62a8be72e7 100644 --- a/test/Sema/method-not-defined.m +++ b/test/Sema/method-not-defined.m @@ -1,6 +1,5 @@ // RUN: clang -fsyntax-only -verify %s -typedef struct objc_object *id; @interface Foo @end diff --git a/test/Sema/selector-1.m b/test/Sema/selector-1.m index 59717c3079..476568f6ca 100644 --- a/test/Sema/selector-1.m +++ b/test/Sema/selector-1.m @@ -1,7 +1,5 @@ // RUN: clang -verify %s -typedef struct objc_selector *SEL; - int main() { SEL s = @selector(retain); SEL s1 = @selector(meth1:); diff --git a/test/Sema/selector-overload.m b/test/Sema/selector-overload.m index e84d21432c..7bd25444c7 100644 --- a/test/Sema/selector-overload.m +++ b/test/Sema/selector-overload.m @@ -1,6 +1,5 @@ // RUN: clang %s -fsyntax-only -typedef struct objc_object *id; @interface NSObject + alloc; - init;