diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2011-06-12 15:46:16 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2011-06-12 15:46:16 +0000 |
commit | 29cafa66ad3878dbb9f82615f19fa0bded2e443c (patch) | |
tree | c5e9e10bc189de0058aa763c47b9920a8351b7df /test/CodeGenObjCXX | |
parent | 01af97d3b23bded2b2b21af19bbc6e4cce49e5b3 (diff) | |
download | src-29cafa66ad3878dbb9f82615f19fa0bded2e443c.tar.gz src-29cafa66ad3878dbb9f82615f19fa0bded2e443c.zip |
Vendor import of clang trunk r132879:vendor/clang/clang-r132879
Notes
Notes:
svn path=/vendor/clang/dist/; revision=223015
svn path=/vendor/clang/clang-r132879/; revision=223016; tag=vendor/clang/clang-r132879
Diffstat (limited to 'test/CodeGenObjCXX')
-rw-r--r-- | test/CodeGenObjCXX/block-in-template-inst.mm | 71 | ||||
-rw-r--r-- | test/CodeGenObjCXX/blocks.mm | 18 | ||||
-rw-r--r-- | test/CodeGenObjCXX/encode.mm | 70 | ||||
-rw-r--r-- | test/CodeGenObjCXX/mangle.mm | 12 | ||||
-rw-r--r-- | test/CodeGenObjCXX/property-object-conditional-exp.mm | 7 |
5 files changed, 176 insertions, 2 deletions
diff --git a/test/CodeGenObjCXX/block-in-template-inst.mm b/test/CodeGenObjCXX/block-in-template-inst.mm new file mode 100644 index 000000000000..72042fc03330 --- /dev/null +++ b/test/CodeGenObjCXX/block-in-template-inst.mm @@ -0,0 +1,71 @@ +// RUN: %clang_cc1 -emit-llvm-only -std=c++0x -fblocks -o - -triple x86_64-apple-darwin10 %s +// rdar://9362021 + +@class DYFuture; +@interface NSCache +- (void)setObject:(id)obj forKey:(id)key; +@end + +template <typename T> +class ResourceManager +{ +public: + ~ResourceManager(); + DYFuture* XXX(); + NSCache* _spDeviceCache; +}; + +template <typename T> +DYFuture* ResourceManager<T>::XXX() +{ + ^ { + [_spDeviceCache setObject:0 forKey:0]; + }(); + + return 0; +} + +struct AnalyzerBaseObjectTypes { }; + +void FUNC() +{ + ResourceManager<AnalyzerBaseObjectTypes> *rm; + ^(void) { rm->XXX(); }(); +} + +namespace PR9982 { + template<typename T> struct Curry; + + template<typename R, typename Arg0, typename Arg1, typename Arg2> + struct Curry<R (^)(Arg0, Arg1, Arg2)> + { + typedef R (^FType)(Arg0, Arg1, Arg2); + + Curry(FType _f) : f(_f) {} + ~Curry() {;} + + R (^(^operator()(Arg0 a))(Arg1))(Arg2) + { + auto block = ^(Arg1 b) { + auto inner_block = ^(Arg2 c) { + return f(a, b, c); + }; + return inner_block; + }; + return block; + } + + private: + FType f; + }; + + auto add = ^(int a, int b, int c) + { + return a + b + c; + }; + + void curry() { + Curry<__decltype(add)> c = Curry<__decltype(add)>(add); + auto t = c(1)(10)(100); + } +} diff --git a/test/CodeGenObjCXX/blocks.mm b/test/CodeGenObjCXX/blocks.mm index ffb916bf0388..e220753ff788 100644 --- a/test/CodeGenObjCXX/blocks.mm +++ b/test/CodeGenObjCXX/blocks.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -fblocks -triple x86_64-apple-darwin %s +// RUN: %clang_cc1 -x objective-c++ -fblocks -triple x86_64-apple-darwin %s -verify -emit-llvm -o %t // rdar://8979379 @interface A @@ -28,3 +28,19 @@ void foo(id <NSObject>(^objectCreationBlock)(void)) { return bar(objectCreationBlock); } +// Test4 +struct S { + S *(^a)() = ^{ // expected-warning {{C++0x}} + return this; + }; +}; +S s; + +// Test5 +struct X { + void f() { + ^ { + struct Nested { Nested *ptr = this; }; // expected-warning {{C++0x}} + } (); + }; +}; diff --git a/test/CodeGenObjCXX/encode.mm b/test/CodeGenObjCXX/encode.mm index 5a49feb706c9..dce3d70665de 100644 --- a/test/CodeGenObjCXX/encode.mm +++ b/test/CodeGenObjCXX/encode.mm @@ -62,3 +62,73 @@ typedef float HGVec4f __attribute__ ((vector_size(16))); @implementation RedBalloonHGXFormWrapper @end +// rdar://9357400 +namespace rdar9357400 { + template<int Dim1 = -1, int Dim2 = -1> struct fixed { + template<int D> struct rebind { typedef fixed<D> other; }; + }; + + template<typename Element, int Size> + class fixed_1D + { + public: + typedef Element value_type; + typedef value_type array_impl[Size]; + protected: + array_impl m_data; + }; + + template<typename Element, typename Alloc> + class vector; + + template<typename Element, int Size> + class vector< Element, fixed<Size> > + : public fixed_1D<Element,Size> { }; + + typedef vector< float, fixed<4> > vector4f; + + // CHECK: @_ZN11rdar9357400L2ggE = internal constant [49 x i8] c"{vector<float, rdar9357400::fixed<4, -1> >=[4f]}\00" + const char gg[] = @encode(vector4f); +} + +struct Base1 { + char x; +}; + +struct DBase : public Base1 { + double x; + virtual ~DBase(); +}; + +struct Sub_with_virt : virtual DBase { + long x; +}; + +struct Sub2 : public Sub_with_virt, public Base1, virtual DBase { + float x; +}; + +// CHECK: @_ZL2g1 = internal constant [10 x i8] c"{Base1=c}\00" +const char g1[] = @encode(Base1); + +// CHECK: @_ZL2g2 = internal constant [14 x i8] c"{DBase=^^?cd}\00" +const char g2[] = @encode(DBase); + +// CHECK: @_ZL2g3 = internal constant [26 x i8] c"{Sub_with_virt=^^?q^^?cd}\00" +const char g3[] = @encode(Sub_with_virt); + +// CHECK: @_ZL2g4 = internal constant [19 x i8] c"{Sub2=^^?qcf^^?cd}\00" +const char g4[] = @encode(Sub2); + +// http://llvm.org/PR9927 +class allocator { +}; +class basic_string { +struct _Alloc_hider : allocator { +char* _M_p; +}; +_Alloc_hider _M_dataplus; +}; + +// CHECK: @_ZL2g5 = internal constant [32 x i8] c"{basic_string={_Alloc_hider=*}}\00" +const char g5[] = @encode(basic_string); diff --git a/test/CodeGenObjCXX/mangle.mm b/test/CodeGenObjCXX/mangle.mm index 7a75a5b40e4c..2521c6076a8c 100644 --- a/test/CodeGenObjCXX/mangle.mm +++ b/test/CodeGenObjCXX/mangle.mm @@ -42,3 +42,15 @@ } @end +// rdar://9566314 +@interface NX +- (void)Meth; +@end + +@implementation NX +- (void)Meth { + void uiIsVisible(); +// CHECK: call void @_Z11uiIsVisiblev + uiIsVisible(); +} +@end diff --git a/test/CodeGenObjCXX/property-object-conditional-exp.mm b/test/CodeGenObjCXX/property-object-conditional-exp.mm index 826c351e79ef..a3c1027ed709 100644 --- a/test/CodeGenObjCXX/property-object-conditional-exp.mm +++ b/test/CodeGenObjCXX/property-object-conditional-exp.mm @@ -23,7 +23,12 @@ extern "C" bool CGRectIsEmpty(CGRect); CGRect virtualBounds; // CHECK: [[SRC:%.*]] = call %struct.CGRect bitcast (i8* (i8*, i8*, ...)* @objc_msgSend -// CHECK-NEXT:store %struct.CGRect [[SRC]], %struct.CGRect* +// CHECK-NEXT:getelementptr %struct.CGRect* [[SRC:%.*]] +// CHECK-NEXT:extractvalue +// CHECK-NEXT:store +// CHECK-NEXT:getelementptr %struct.CGRect* [[SRC:%.*]] +// CHECK-NEXT:extractvalue +// CHECK-NEXT:store dataRect = CGRectIsEmpty(virtualBounds) ? self.bounds : virtualBounds; dataRect = CGRectIsEmpty(virtualBounds) ? [self bounds] : virtualBounds; dataRect = CGRectIsEmpty(virtualBounds) ? virtualBounds : self.bounds; |