summaryrefslogtreecommitdiffstats
path: root/test/Rewriter
diff options
context:
space:
mode:
Diffstat (limited to 'test/Rewriter')
-rw-r--r--test/Rewriter/line-generation-test.m40
-rw-r--r--test/Rewriter/modern-write-bf-abi.mm120
-rw-r--r--test/Rewriter/objc-modern-property-bitfield.m43
-rw-r--r--test/Rewriter/rewrite-line-directive.m18
-rw-r--r--test/Rewriter/rewrite-modern-qualified-type.mm11
-rw-r--r--test/Rewriter/rewrite-modern-throw.m26
-rw-r--r--test/Rewriter/unnamed-bf-modern-write.mm16
7 files changed, 268 insertions, 6 deletions
diff --git a/test/Rewriter/line-generation-test.m b/test/Rewriter/line-generation-test.m
new file mode 100644
index 0000000..dad7371
--- /dev/null
+++ b/test/Rewriter/line-generation-test.m
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang_cc1 -fms-extensions -rewrite-objc -g %t.mm -o %t-rw.cpp
+// RUN: FileCheck -check-prefix LINE --input-file=%t-rw.cpp %s
+// RUN: %clang_cc1 -fms-extensions -rewrite-objc %t.mm -o %t-rwnog.cpp
+// RUN: FileCheck -check-prefix NOLINE --input-file=%t-rwnog.cpp %s
+// rdar://13138170
+
+__attribute__((objc_root_class)) @interface MyObject {
+@public
+ id _myMaster;
+ id _isTickledPink;
+}
+@property(retain) id myMaster;
+@property(assign) id isTickledPink;
+@end
+
+@implementation MyObject
+
+@synthesize myMaster = _myMaster;
+@synthesize isTickledPink = _isTickledPink;
+
+- (void) doSomething {
+ _myMaster = _isTickledPink;
+}
+
+@end
+
+MyObject * foo ()
+{
+ MyObject* p;
+ p.isTickledPink = p.myMaster; // ok
+ p->_isTickledPink = p->_myMaster;
+ return p->_isTickledPink;
+}
+
+// CHECK-LINE: #line 22
+// CHECK-LINE: #line 28
+// CHECK-NOLINE-NOT: #line 22
+// CHECK-NOLINE-NOT: #line 28
+
diff --git a/test/Rewriter/modern-write-bf-abi.mm b/test/Rewriter/modern-write-bf-abi.mm
new file mode 100644
index 0000000..85db939
--- /dev/null
+++ b/test/Rewriter/modern-write-bf-abi.mm
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// rdar://13138459
+
+// -Did="void*" -DSEL="void *" -DClass="void*"
+@interface NSMutableArray {
+ id isa;
+}
+@end
+
+typedef unsigned char BOOL;
+typedef unsigned long NSUInteger;
+
+__attribute__((visibility("hidden")))
+@interface __NSArrayM : NSMutableArray {
+ NSUInteger _used;
+ NSUInteger _doHardRetain:1;
+ NSUInteger _doWeakAccess:1;
+#if __LP64__
+ NSUInteger _size:62;
+#else
+ NSUInteger _size:30;
+#endif
+ NSUInteger _hasObjects:1;
+ NSUInteger _hasStrongReferences:1;
+#if __LP64__
+ NSUInteger _offset:62;
+#else
+ NSUInteger _offset:30;
+#endif
+ unsigned long _mutations;
+ id *_list;
+}
+@end
+
+
+id __CFAllocateObject2();
+BOOL objc_collectingEnabled();
+
+@implementation __NSArrayM
++ (id)__new:(const id [])objects :(NSUInteger)count :(BOOL)hasObjects :(BOOL)hasStrong :(BOOL)transferRetain {
+ __NSArrayM *newArray = (__NSArrayM *)__CFAllocateObject2();
+ newArray->_size = count;
+ newArray->_mutations = 1;
+ newArray->_doHardRetain = (hasObjects && hasStrong);
+ newArray->_doWeakAccess = (objc_collectingEnabled() && !hasStrong);
+ newArray->_hasObjects = hasObjects;
+ newArray->_hasStrongReferences = hasStrong;
+ newArray->_list = 0;
+ return *newArray->_list;
+}
+@end
+
+// Test2
+@interface Super {
+ int ivar_super_a : 5;
+}
+@end
+
+@interface A : Super {
+@public
+ int ivar_a : 5;
+}
+@end
+
+int f0(A *a) {
+ return a->ivar_a;
+}
+
+@interface A () {
+@public
+ int ivar_ext_a : 5;
+ int ivar_ext_b : 5;
+}@end
+
+int f1(A *a) {
+ return a->ivar_ext_a + a->ivar_a;
+}
+
+@interface A () {
+@public
+ int ivar_ext2_a : 5;
+ int ivar_ext2_b : 5;
+}@end
+
+int f2(A* a) {
+ return a->ivar_ext2_a + a->ivar_ext_a + a->ivar_a;
+}
+
+@implementation A {
+@public
+ int ivar_b : 5;
+ int ivar_c : 5;
+ int ivar_d : 5;
+}
+@end
+
+int f3(A *a) {
+ return a->ivar_d + a->ivar_ext2_a + a->ivar_ext_a + a->ivar_a;
+}
+
+__attribute__((objc_root_class)) @interface Base
+{
+ struct objc_class *isa;
+ int full;
+ int full2: 32;
+ int _refs: 8;
+ int field2: 3;
+ unsigned f3: 8;
+ short cc;
+ unsigned g: 16;
+ int r2: 8;
+ int r3: 8;
+ int r4: 2;
+ int r5: 8;
+ char c;
+}
+@end
+
+@implementation Base @end
diff --git a/test/Rewriter/objc-modern-property-bitfield.m b/test/Rewriter/objc-modern-property-bitfield.m
new file mode 100644
index 0000000..583fa37
--- /dev/null
+++ b/test/Rewriter/objc-modern-property-bitfield.m
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// rdar://13138459
+
+void *sel_registerName(const char *);
+extern void abort();
+
+@interface NSObject
++ alloc;
+- init;
+@end
+
+typedef unsigned char BOOL;
+
+@interface Foo : NSObject {
+
+ BOOL _field1 : 5;
+ BOOL _field2 : 3;
+}
+
+@property BOOL field1;
+@property BOOL field2;
+@end
+
+@implementation Foo
+
+@synthesize field1 = _field1;
+@synthesize field2 = _field2;
+
+@end
+
+int main()
+{
+ Foo *f = (Foo*)[[Foo alloc] init];
+ f.field1 = 0xF;
+ f.field2 = 0x3;
+ f.field1 = f.field1 & f.field2;
+ if (f.field1 != 0x3)
+ abort ();
+ return 0;
+}
+
+
diff --git a/test/Rewriter/rewrite-line-directive.m b/test/Rewriter/rewrite-line-directive.m
new file mode 100644
index 0000000..5c4e957
--- /dev/null
+++ b/test/Rewriter/rewrite-line-directive.m
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -E %s -o %t.mm
+// RUN: %clang -fms-extensions -rewrite-objc %t.mm -o %t-rw.cpp
+// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s
+// RUN: %clang -g -fms-extensions -rewrite-objc %t.mm -o %t-rw.cpp
+// RUN: FileCheck -check-prefix LPG --input-file=%t-rw.cpp %s
+// rdar://13138170
+
+int z();
+
+int x() {
+ id foo;
+ for (id y in foo) {
+ z();
+ }
+ return 0;
+}
+// CHECK-LP-NOT: #line
+// CHECK-LPG: #line
diff --git a/test/Rewriter/rewrite-modern-qualified-type.mm b/test/Rewriter/rewrite-modern-qualified-type.mm
new file mode 100644
index 0000000..53e0d23
--- /dev/null
+++ b/test/Rewriter/rewrite-modern-qualified-type.mm
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D_Bool=bool -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// rdar://13562505
+
+@protocol OS_dispatch_object @end
+
+@interface NSObject @end
+
+@protocol OS_dispatch_queue <OS_dispatch_object> @end typedef NSObject<OS_dispatch_queue> *dispatch_queue_t;
+
+typedef id<OS_dispatch_queue> dispatch_queue_i;
diff --git a/test/Rewriter/rewrite-modern-throw.m b/test/Rewriter/rewrite-modern-throw.m
index 1912384..1564611 100644
--- a/test/Rewriter/rewrite-modern-throw.m
+++ b/test/Rewriter/rewrite-modern-throw.m
@@ -65,3 +65,29 @@ int main()
}
}
@end
+
+// rdar://13186010
+@class NSDictionary, NSException;
+@class NSMutableDictionary;
+
+@interface NSString
++ (id)stringWithFormat:(NSString *)format, ... ;
+@end
+
+@interface NSException
++ (NSException *)exceptionWithName:(NSString *)name reason:(NSString *)reason userInfo:(NSDictionary *)userInfo;
+@end
+id *_imp__NSInvalidArgumentException;
+
+@interface NSSetExpression @end
+
+@implementation NSSetExpression
+-(id)expressionValueWithObject:(id)object context:(NSMutableDictionary*)bindings {
+ id leftSet;
+ id rightSet;
+ @throw [NSException exceptionWithName: *_imp__NSInvalidArgumentException reason: [NSString stringWithFormat: @"Can't evaluate set expression; left subexpression not a set (lhs = %@ rhs = %@)", leftSet, rightSet] userInfo: 0];
+
+ return leftSet ;
+}
+@end
+
diff --git a/test/Rewriter/unnamed-bf-modern-write.mm b/test/Rewriter/unnamed-bf-modern-write.mm
index 892382f..209cdd6 100644
--- a/test/Rewriter/unnamed-bf-modern-write.mm
+++ b/test/Rewriter/unnamed-bf-modern-write.mm
@@ -1,5 +1,6 @@
// RUN: %clang_cc1 -E %s -o %t.mm
// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s
+// rdar://13138459
@interface Foo {
@private
@@ -13,11 +14,14 @@
@implementation Foo
@end
+// CHECK: struct Foo__T_1 {
+// CHECK-NEXT: int : 1;
+// CHECK-NEXT: int third : 1;
+// CHECK-NEXT: int : 1;
+// CHECK-NEXT: int fifth : 1;
+// CHECK-NEXT: char : 0;
+// CHECK-NEXT: } ;
// CHECK: struct Foo_IMPL {
-// CHECK-NEXT: int first;
-// CHECK-NEXT: int : 1;
-// CHECK-NEXT: int third : 1;
-// CHECK-NEXT: int : 1;
-// CHECK-NEXT: int fifth : 1;
-// CHECK-NEXT: char : 0;
+// CHECK-NEXT: int first;
+// CHECK-NEXT: struct Foo__T_1 Foo__GRBF_1;
// CHECK-NEXT: };
OpenPOWER on IntegriCloud