diff options
Diffstat (limited to 'test/CodeGenObjCXX')
-rw-r--r-- | test/CodeGenObjCXX/arc-cxx11-init-list.mm | 55 | ||||
-rw-r--r-- | test/CodeGenObjCXX/arc-cxx11-member-init.mm | 17 | ||||
-rw-r--r-- | test/CodeGenObjCXX/arc-references.mm | 2 | ||||
-rw-r--r-- | test/CodeGenObjCXX/arc.mm | 2 | ||||
-rw-r--r-- | test/CodeGenObjCXX/block-id.mm | 22 | ||||
-rw-r--r-- | test/CodeGenObjCXX/debug-info-line.mm | 30 | ||||
-rw-r--r-- | test/CodeGenObjCXX/destroy.mm | 50 | ||||
-rw-r--r-- | test/CodeGenObjCXX/externally-initialized-selectors.mm | 2 | ||||
-rw-r--r-- | test/CodeGenObjCXX/lambda-expressions.mm | 4 | ||||
-rw-r--r-- | test/CodeGenObjCXX/lvalue-reference-getter.mm | 2 | ||||
-rw-r--r-- | test/CodeGenObjCXX/mangle-blocks.mm | 13 | ||||
-rw-r--r-- | test/CodeGenObjCXX/property-lvalue-capture.mm | 6 | ||||
-rw-r--r-- | test/CodeGenObjCXX/property-object-reference.mm | 4 | ||||
-rw-r--r-- | test/CodeGenObjCXX/property-objects.mm | 7 | ||||
-rw-r--r-- | test/CodeGenObjCXX/subst-sel.mm | 4 |
15 files changed, 199 insertions, 21 deletions
diff --git a/test/CodeGenObjCXX/arc-cxx11-init-list.mm b/test/CodeGenObjCXX/arc-cxx11-init-list.mm new file mode 100644 index 0000000..da214dc --- /dev/null +++ b/test/CodeGenObjCXX/arc-cxx11-init-list.mm @@ -0,0 +1,55 @@ +// RUN: %clang_cc1 -triple armv7-ios5.0 -std=c++11 -fobjc-arc -Os -emit-llvm -o - %s | FileCheck %s + +typedef __SIZE_TYPE__ size_t; + +namespace std { +template <typename _Ep> +class initializer_list { + const _Ep* __begin_; + size_t __size_; + + initializer_list(const _Ep* __b, size_t __s); +}; +} + +@interface I ++ (instancetype) new; +@end + +void function(std::initializer_list<I *>); + +extern "C" void single() { function({ [I new] }); } + +// CHECK: [[INSTANCE:%.*]] = {{.*}} call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}}) +// CHECK-NEXT: [[CAST:%.*]] = bitcast [{{[0-9]+}} x %0*]* %{{.*}} to i8** +// CHECK-NEXT: store i8* [[INSTANCE]], i8** [[CAST]], +// CHECK: call void @objc_release(i8* {{.*}}) + +extern "C" void multiple() { function({ [I new], [I new] }); } + +// CHECK: [[INSTANCE:%.*]] = {{.*}} call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}}) +// CHECK-NEXT: [[CAST:%.*]] = bitcast [{{[0-9]+}} x %0*]* %{{.*}} to i8** +// CHECK-NEXT: store i8* [[INSTANCE]], i8** [[CAST]], +// CHECK: call void @objc_release(i8* {{.*}}) +// CHECK-NEXT: icmp eq + +void external(); + +extern "C" void extended() { + const auto && temporary = { [I new] }; + external(); +} + +// CHECK: [[INSTANCE:%.*]] = {{.*}} call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}}) +// CHECK-NEXT: [[CAST:%.*]] = bitcast [1 x %0*]* %{{.*}} to i8** +// CHECK-NEXT: store i8* [[INSTANCE]], i8** [[CAST]], +// CHECK: {{.*}} call void @_Z8externalv() +// CHECK: {{.*}} call void @objc_release(i8* {{.*}}) + +std::initializer_list<I *> il = { [I new] }; + +// CHECK: [[POOL:%.*]] = {{.*}} call i8* @objc_autoreleasePoolPush() +// CHECK: [[INSTANCE:%.*]] = {{.*}} call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}}) +// CHECK-NEXT: store i8* [[INSTANCE]], i8** bitcast ([1 x %0*]* @_ZGR2il_ to i8**) +// CHECK: {{.*}} call void @objc_autoreleasePoolPop(i8* [[POOL]]) + diff --git a/test/CodeGenObjCXX/arc-cxx11-member-init.mm b/test/CodeGenObjCXX/arc-cxx11-member-init.mm index 213e7a1..5129f9fa 100644 --- a/test/CodeGenObjCXX/arc-cxx11-member-init.mm +++ b/test/CodeGenObjCXX/arc-cxx11-member-init.mm @@ -23,10 +23,23 @@ class XClipboardDataSet @end // CHECK: [[mClipData:%.*]] = getelementptr inbounds %class.XClipboardDataSet* -// CHECK: [[ZERO:%.*]] = load %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_" -// CHECK: [[ONE:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_" +// CHECK: [[ZERO:%.*]] = load %struct._class_t** @"OBJC_CLASSLIST_REFERENCES_$_" +// CHECK: [[ONE:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_ // CHECK: [[TWO:%.*]] = bitcast %struct._class_t* [[ZERO]] to i8* // CHECK: [[CALL:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* [[TWO]], i8* [[ONE]]) // CHECK: [[THREE:%.*]] = bitcast i8* [[CALL]] to [[T:%.*]]* // CHECK: store [[T]]* [[THREE]], [[T]]** [[mClipData]], align 8 +// rdar://18950072 +struct Butt { }; + +__attribute__((objc_root_class)) +@interface Foo { + Butt x; + Butt y; + Butt z; +} +@end +@implementation Foo +@end +// CHECK-NOT: define internal i8* @"\01-[Foo .cxx_construct diff --git a/test/CodeGenObjCXX/arc-references.mm b/test/CodeGenObjCXX/arc-references.mm index 10e7f64..0acb6d5 100644 --- a/test/CodeGenObjCXX/arc-references.mm +++ b/test/CodeGenObjCXX/arc-references.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -O2 -disable-llvm-optzns -o - %s | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -O2 -disable-llvm-optzns -o - %s | FileCheck %s @interface A @end diff --git a/test/CodeGenObjCXX/arc.mm b/test/CodeGenObjCXX/arc.mm index e31b094..6b42a4c 100644 --- a/test/CodeGenObjCXX/arc.mm +++ b/test/CodeGenObjCXX/arc.mm @@ -203,7 +203,7 @@ template void test37<Test37>(Test37 *a); // CHECK-NEXT: [[COLL:%.*]] = bitcast i8* [[T2]] to [[NSARRAY]]* // Make sure it's not immediately released before starting the iteration. -// CHECK-NEXT: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_ +// CHECK-NEXT: load i8** @OBJC_SELECTOR_REFERENCES_ // CHECK-NEXT: [[T0:%.*]] = bitcast [[NSARRAY]]* [[COLL]] to i8* // CHECK-NEXT: @objc_msgSend diff --git a/test/CodeGenObjCXX/block-id.mm b/test/CodeGenObjCXX/block-id.mm new file mode 100644 index 0000000..e324841 --- /dev/null +++ b/test/CodeGenObjCXX/block-id.mm @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck %s + +// N.B. This test verifies that two blocks which are otherwise +// indistinguishable receive distinct manglings. +// We had a bug where the first two blocks in the global block map could +// get the same unqualified-block mangling because the logic to handle +// block-ids believed it was handling Itanium-style discriminators. + +template<typename T> +int tf() { + return T::value; +} +int i1 = ^int { + struct S { enum { value = 1 };}; + // CHECK-DAG: @_Z2tfIZUb_E1SEiv + return tf<S>(); +}(); +int i2 = ^int(int p1) { + struct S { enum { value = 2 };}; + // CHECK-DAG: @_Z2tfIZUb0_E1SEiv + return tf<S>() + p1; +}(1); diff --git a/test/CodeGenObjCXX/debug-info-line.mm b/test/CodeGenObjCXX/debug-info-line.mm new file mode 100644 index 0000000..4c934f1 --- /dev/null +++ b/test/CodeGenObjCXX/debug-info-line.mm @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -gline-tables-only -fblocks -emit-llvm %s -o - | FileCheck %s + +void fn(); + +struct foo { + ~foo(); +}; + +void f1() { + ^{ + foo f; + fn(); + // CHECK: cleanup, !dbg [[DBG_F1:![0-9]*]] +#line 100 + }(); +} + +// CHECK-LABEL: define internal i8* @"\01-[TNSObject init]" +@implementation TNSObject +- (id)init +{ + foo f; + fn(); + // CHECK: cleanup, !dbg [[DBG_TNSO:![0-9]*]] +#line 200 +} +@end + +// CHECK: [[DBG_F1]] = !MDLocation(line: 100, +// CHECK: [[DBG_TNSO]] = !MDLocation(line: 200, diff --git a/test/CodeGenObjCXX/destroy.mm b/test/CodeGenObjCXX/destroy.mm new file mode 100644 index 0000000..c53ac39 --- /dev/null +++ b/test/CodeGenObjCXX/destroy.mm @@ -0,0 +1,50 @@ +// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -disable-llvm-optzns -o - %s | FileCheck %s +// rdar://18249673 + +@class MyObject; +struct base { + ~base() = default; +}; +struct derived : public base { + MyObject *myobject; +}; + +void test1() { + derived d1; +} +// CHECK-LABEL: define void @_Z5test1v() +// CHECK: call void @_ZN7derivedC1Ev +// CHECK: call void @_ZN7derivedD1Ev + +void test2() { + derived *d2 = new derived; + delete d2; +} +// CHECK-LABEL: define void @_Z5test2v() +// CHECK: call void @_ZN7derivedC1Ev +// CHECK: call void @_ZN7derivedD1Ev + +template <typename T> +struct tderived : public base { + MyObject *myobject; +}; +void test3() { + tderived<int> d1; +} +// CHECK-LABEL: define void @_Z5test3v() +// CHECK: call void @_ZN8tderivedIiEC1Ev +// CHECK: call void @_ZN8tderivedIiED1Ev + +void test4() { + tderived<int> *d2 = new tderived<int>; + delete d2; +} +// CHECK-LABEL: define void @_Z5test4v() +// CHECK: call void @_ZN8tderivedIiEC1Ev +// CHECK: call void @_ZN8tderivedIiED1Ev + +// CHECK-LABEL: define linkonce_odr void @_ZN8tderivedIiED2Ev +// CHECK: call void @objc_storeStrong(i8** {{.*}}, i8* null) + +// CHECK-LABEL: define linkonce_odr void @_ZN7derivedD2Ev +// CHECK: call void @objc_storeStrong(i8** {{.*}}, i8* null) diff --git a/test/CodeGenObjCXX/externally-initialized-selectors.mm b/test/CodeGenObjCXX/externally-initialized-selectors.mm index 0b7c24e..7dcd727 100644 --- a/test/CodeGenObjCXX/externally-initialized-selectors.mm +++ b/test/CodeGenObjCXX/externally-initialized-selectors.mm @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.5 -o - -emit-llvm %s | FileCheck %s // RUN: %clang_cc1 -o - -emit-llvm %s | FileCheck %s -// CHECK: @"\01L_OBJC_SELECTOR_REFERENCES_" = private externally_initialized global +// CHECK: @OBJC_SELECTOR_REFERENCES_ = private externally_initialized global void test(id x) { [x doSomething]; diff --git a/test/CodeGenObjCXX/lambda-expressions.mm b/test/CodeGenObjCXX/lambda-expressions.mm index 435f805..9129ff0 100644 --- a/test/CodeGenObjCXX/lambda-expressions.mm +++ b/test/CodeGenObjCXX/lambda-expressions.mm @@ -4,8 +4,8 @@ typedef int (^fp)(); fp f() { auto x = []{ return 3; }; return x; } -// MRC: @"\01L_OBJC_METH_VAR_NAME{{.*}}" = private global [5 x i8] c"copy\00" -// MRC: @"\01L_OBJC_METH_VAR_NAME{{.*}}" = private global [12 x i8] c"autorelease\00" +// MRC: @OBJC_METH_VAR_NAME{{.*}} = private global [5 x i8] c"copy\00" +// MRC: @OBJC_METH_VAR_NAME{{.*}} = private global [12 x i8] c"autorelease\00" // MRC-LABEL: define i32 ()* @_Z1fv( // MRC-LABEL: define internal i32 ()* @"_ZZ1fvENK3$_0cvU13block_pointerFivEEv" // MRC: store i8* bitcast (i8** @_NSConcreteStackBlock to i8*) diff --git a/test/CodeGenObjCXX/lvalue-reference-getter.mm b/test/CodeGenObjCXX/lvalue-reference-getter.mm index 5205a7c..87c1320 100644 --- a/test/CodeGenObjCXX/lvalue-reference-getter.mm +++ b/test/CodeGenObjCXX/lvalue-reference-getter.mm @@ -23,6 +23,6 @@ static SetSection gSetSection; // CHECK: [[SELF:%.*]] = alloca [[T6:%.*]]*, align // CHECK: [[T0:%.*]] = load {{.*}}* [[SELF]], align -// CHECK: [[T1:%.*]] = load {{.*}}* @"\01L_OBJC_SELECTOR_REFERENCES_" +// CHECK: [[T1:%.*]] = load {{.*}}* @OBJC_SELECTOR_REFERENCES_ // CHECK: [[C:%.*]] = call dereferenceable({{[0-9]+}}) %struct.SetSection* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend // CHECK: call dereferenceable({{[0-9]+}}) i32* @_ZN10SetSection2atEi(%struct.SetSection* [[C]] diff --git a/test/CodeGenObjCXX/mangle-blocks.mm b/test/CodeGenObjCXX/mangle-blocks.mm index 405e528..1f3f163 100644 --- a/test/CodeGenObjCXX/mangle-blocks.mm +++ b/test/CodeGenObjCXX/mangle-blocks.mm @@ -1,9 +1,8 @@ // RUN: %clang_cc1 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck %s -// CHECK: @_ZGVZZ3foovEUb_E5value = internal global i64 0 -// CHECK: @_ZZZN26externally_visible_statics1S3fooEiEd_Ub_E1k = linkonce_odr global i32 0 -// CHECK: @_ZZ26externally_visible_statics1S1xMUb_E1j = linkonce_odr global i32 0 -// CHECK: @_ZZZN26externally_visible_statics10inlinefuncEvEUb_E1i = linkonce_odr global i32 0 +// CHECK: @_ZZZN26externally_visible_statics1S3fooEiEd_Ub0_E1k = linkonce_odr global i32 0 +// CHECK: @_ZZ26externally_visible_statics1S1xMUb0_E1j = linkonce_odr global i32 0 +// CHECK: @_ZZZN26externally_visible_statics10inlinefuncEvEUb0_E1i = linkonce_odr global i32 0 int f(); @@ -27,7 +26,7 @@ int i = ^(int x) { return x;}(i); - (void)method { // CHECK: define internal signext i8 @"__11-[A method]_block_invoke" (void)^(int x) { - // CHECK: @"_ZZZ11-[A method]EUb0_E4name" + // CHECK: @"_ZZZ11-[A method]EUb1_E4name" static const char *name = "hello"; return name[x]; }; @@ -45,7 +44,7 @@ namespace N { // CHECK-LABEL: define internal signext i8 @___Z3fooi_block_invoke void bar() { (void)^(int x) { - // CHECK: @_ZZZN1N3barEvEUb2_E4name + // CHECK: @_ZZZN1N3barEvEUb3_E4name static const char *name = "hello"; return name[x]; }; @@ -57,7 +56,7 @@ class C { }; C::C() { (void)^(int x) { - // CHECK: @_ZZZN1CC1EvEUb3_E5nameb + // CHECK: @_ZZZN1CC1EvEUb4_E5nameb static const char *nameb = "hello"; return nameb[x]; }; diff --git a/test/CodeGenObjCXX/property-lvalue-capture.mm b/test/CodeGenObjCXX/property-lvalue-capture.mm index 690ffa9..1242246 100644 --- a/test/CodeGenObjCXX/property-lvalue-capture.mm +++ b/test/CodeGenObjCXX/property-lvalue-capture.mm @@ -24,10 +24,10 @@ typedef Quad2<double> Quad2d; } @end -// CHECK: [[TWO:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_", !invariant.load ![[MD_NUM:[0-9]+]] +// CHECK: [[TWO:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_, !invariant.load ![[MD_NUM:[0-9]+]] // CHECK: [[THREE:%.*]] = bitcast [[ONET:%.*]]* [[ONE:%.*]] to i8* // CHECK: [[CALL:%.*]] = call nonnull %struct.Quad2* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to %struct.Quad2* (i8*, i8*)*)(i8* [[THREE]], i8* [[TWO]]) -// CHECK: [[FOUR:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_2", !invariant.load ![[MD_NUM]] +// CHECK: [[FOUR:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_2, !invariant.load ![[MD_NUM]] // CHECK: [[FIVE:%.*]] = bitcast [[ONET]]* [[ZERO:%.*]] to i8* // CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, %struct.Quad2*)*)(i8* [[FIVE]], i8* [[FOUR]], %struct.Quad2* nonnull [[CALL]]) @@ -47,7 +47,7 @@ void test(C *c, const A &a) { } // CHECK: [[ONE1:%.*]] = load %struct.A** [[AADDR:%.*]], align 8 -// CHECK: [[TWO1:%.*]] = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_5", !invariant.load ![[MD_NUM]] +// CHECK: [[TWO1:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_5, !invariant.load ![[MD_NUM]] // CHECK: [[THREE1:%.*]] = bitcast [[TWOT:%.*]]* [[ZERO1:%.*]] to i8* // CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, %struct.A*)*)(i8* [[THREE1]], i8* [[TWO1]], %struct.A* dereferenceable({{[0-9]+}}) [[ONE1]]) // CHECK: store %struct.A* [[ONE1]], %struct.A** [[RESULT:%.*]], align 8 diff --git a/test/CodeGenObjCXX/property-object-reference.mm b/test/CodeGenObjCXX/property-object-reference.mm index ec311f1..691e6ff 100644 --- a/test/CodeGenObjCXX/property-object-reference.mm +++ b/test/CodeGenObjCXX/property-object-reference.mm @@ -25,11 +25,11 @@ static Foo gFoo; @end // CHECK: [[T0:%.*]] = load {{%.*}} [[S0:%.*]] -// CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_ +// CHECK: load i8** @OBJC_SELECTOR_REFERENCES_ // CHECK: [[T2:%.*]] = bitcast {{%.*}} [[T0]] to i8* // CHECK: @objc_msgSend // CHECK: [[R0:%.*]] = load {{%.*}} [[U0:%.*]] -// CHECK: load i8** @"\01L_OBJC_SELECTOR_REFERENCES_ +// CHECK: load i8** @OBJC_SELECTOR_REFERENCES_ // CHECK: [[R2:%.*]] = bitcast {{%.*}} [[R0]] to i8* // CHECK: @objc_msgSend diff --git a/test/CodeGenObjCXX/property-objects.mm b/test/CodeGenObjCXX/property-objects.mm index c79c280..73ed21d 100644 --- a/test/CodeGenObjCXX/property-objects.mm +++ b/test/CodeGenObjCXX/property-objects.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -g -o - | FileCheck %s class S { public: @@ -35,6 +35,11 @@ struct CGRect { // CHECK: call dereferenceable({{[0-9]+}}) %class.S* @_ZN1SaSERKS_ // CHECK-NEXT: ret void +// Don't attach debug locations to the prologue instructions. These were +// leaking over from the previous function emission by accident. +// CHECK: define internal void @"\01-[I setBounds:]" +// CHECK-NOT: !dbg +// CHECK: call void @llvm.dbg.declare - (void)setFrame:(CGRect)frameRect {} - (CGRect)frame {return bounds;} diff --git a/test/CodeGenObjCXX/subst-sel.mm b/test/CodeGenObjCXX/subst-sel.mm new file mode 100644 index 0000000..f4a2b84 --- /dev/null +++ b/test/CodeGenObjCXX/subst-sel.mm @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s + +// CHECK: @_Z4bad1P8NSObjectP13objc_selectorP11objc_objectS4_ +void bad1(struct NSObject *, SEL, id, id) {} |