[cfe-commits] r43077 - in /cfe/trunk: 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
Steve Naroff
snaroff at apple.com
Wed Oct 17 10:53:50 PDT 2007
Author: snaroff
Date: Wed Oct 17 12:53:50 2007
New Revision: 43077
URL: http://llvm.org/viewvc/llvm-project?rev=43077&view=rev
Log:
Predefine all the ObjC goodies from <objc/objc.h>. Removed all the ObjC goodies from the respective test files. Moving forward, it will be very nice to assume these builtin!
Modified:
cfe/trunk/Lex/Preprocessor.cpp
cfe/trunk/test/Sema/argument-checking.m
cfe/trunk/test/Sema/id_not_builtin.m
cfe/trunk/test/Sema/method-not-defined.m
cfe/trunk/test/Sema/selector-1.m
cfe/trunk/test/Sema/selector-overload.m
Modified: cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/Preprocessor.cpp?rev=43077&r1=43076&r2=43077&view=diff
==============================================================================
--- cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/Lex/Preprocessor.cpp Wed Oct 17 12:53:50 2007
@@ -371,9 +371,27 @@
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.
Modified: cfe/trunk/test/Sema/argument-checking.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/argument-checking.m?rev=43077&r1=43076&r2=43077&view=diff
==============================================================================
--- cfe/trunk/test/Sema/argument-checking.m (original)
+++ cfe/trunk/test/Sema/argument-checking.m Wed Oct 17 12:53:50 2007
@@ -1,7 +1,5 @@
// RUN: clang -fsyntax-only -verify %s
-typedef struct objc_object *id;
-
struct S { int a; };
extern int charStarFunc(char *);
Modified: cfe/trunk/test/Sema/id_not_builtin.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/id_not_builtin.m?rev=43077&r1=43076&r2=43077&view=diff
==============================================================================
--- cfe/trunk/test/Sema/id_not_builtin.m (original)
+++ cfe/trunk/test/Sema/id_not_builtin.m Wed Oct 17 12:53:50 2007
@@ -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
Modified: cfe/trunk/test/Sema/method-not-defined.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/method-not-defined.m?rev=43077&r1=43076&r2=43077&view=diff
==============================================================================
--- cfe/trunk/test/Sema/method-not-defined.m (original)
+++ cfe/trunk/test/Sema/method-not-defined.m Wed Oct 17 12:53:50 2007
@@ -1,6 +1,5 @@
// RUN: clang -fsyntax-only -verify %s
-typedef struct objc_object *id;
@interface Foo
@end
Modified: cfe/trunk/test/Sema/selector-1.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/selector-1.m?rev=43077&r1=43076&r2=43077&view=diff
==============================================================================
--- cfe/trunk/test/Sema/selector-1.m (original)
+++ cfe/trunk/test/Sema/selector-1.m Wed Oct 17 12:53:50 2007
@@ -1,7 +1,5 @@
// RUN: clang -verify %s
-typedef struct objc_selector *SEL;
-
int main() {
SEL s = @selector(retain);
SEL s1 = @selector(meth1:);
Modified: cfe/trunk/test/Sema/selector-overload.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/selector-overload.m?rev=43077&r1=43076&r2=43077&view=diff
==============================================================================
--- cfe/trunk/test/Sema/selector-overload.m (original)
+++ cfe/trunk/test/Sema/selector-overload.m Wed Oct 17 12:53:50 2007
@@ -1,6 +1,5 @@
// RUN: clang %s -fsyntax-only
-typedef struct objc_object *id;
@interface NSObject
+ alloc;
- init;
More information about the cfe-commits
mailing list