forked from OSchip/llvm-project
Add test cases that weren't committed in r313945.
llvm-svn: 313952
This commit is contained in:
parent
388b012f4e
commit
6c2dbc69a7
|
@ -0,0 +1,67 @@
|
|||
// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s
|
||||
|
||||
struct S {
|
||||
int a[4];
|
||||
S(int *, int * __attribute__((noescape)));
|
||||
S &operator=(int * __attribute__((noescape)));
|
||||
void m0(int *, int * __attribute__((noescape)));
|
||||
virtual void vm1(int *, int * __attribute__((noescape)));
|
||||
};
|
||||
|
||||
// CHECK: define void @_ZN1SC2EPiS0_(%struct.S* {{.*}}, {{.*}}, {{.*}} nocapture)
|
||||
// CHECK: define void @_ZN1SC1EPiS0_(%struct.S* {{.*}}, {{.*}}, {{.*}} nocapture) {{.*}} {
|
||||
// CHECK: call void @_ZN1SC2EPiS0_(%struct.S* {{.*}}, {{.*}}, {{.*}} nocapture {{.*}})
|
||||
|
||||
S::S(int *, int * __attribute__((noescape))) {}
|
||||
|
||||
// CHECK: define {{.*}} %struct.S* @_ZN1SaSEPi(%struct.S* {{.*}}, {{.*}} nocapture)
|
||||
S &S::operator=(int * __attribute__((noescape))) { return *this; }
|
||||
|
||||
// CHECK: define void @_ZN1S2m0EPiS0_(%struct.S* {{.*}}, {{.*}} nocapture)
|
||||
void S::m0(int *, int * __attribute__((noescape))) {}
|
||||
|
||||
// CHECK: define void @_ZN1S3vm1EPiS0_(%struct.S* {{.*}}, {{.*}} nocapture)
|
||||
void S::vm1(int *, int * __attribute__((noescape))) {}
|
||||
|
||||
// CHECK-LABEL: define void @_Z5test0P1SPiS1_(
|
||||
// CHECK: call void @_ZN1SC1EPiS0_(%struct.S* {{.*}}, {{.*}}, {{.*}} nocapture {{.*}})
|
||||
// CHECK: call {{.*}} %struct.S* @_ZN1SaSEPi(%struct.S* {{.*}}, {{.*}} nocapture {{.*}})
|
||||
// CHECK: call void @_ZN1S2m0EPiS0_(%struct.S* {{.*}}, {{.*}}, {{.*}} nocapture {{.*}})
|
||||
// CHECK: call void {{.*}}(%struct.S* {{.*}}, {{.*}}, {{.*}} nocapture {{.*}})
|
||||
void test0(S *s, int *p0, int *p1) {
|
||||
S t(p0, p1);
|
||||
t = p1;
|
||||
s->m0(p0, p1);
|
||||
s->vm1(p0, p1);
|
||||
}
|
||||
|
||||
namespace std {
|
||||
typedef decltype(sizeof(0)) size_t;
|
||||
}
|
||||
|
||||
// CHECK: define {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
|
||||
void *operator new(std::size_t, void * __attribute__((noescape)) p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define i8* @_Z5test1Pv(
|
||||
// CHECK : %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
|
||||
void *test1(void *p0) {
|
||||
return ::operator new(16, p0);
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define void @_Z5test2PiS_(
|
||||
// CHECK: call void @"_ZZ5test2PiS_ENK3$_0clES_S_"({{.*}}, {{.*}}, {{.*}} nocapture {{.*}})
|
||||
// CHECK: define internal void @"_ZZ5test2PiS_ENK3$_0clES_S_"({{.*}}, {{.*}}, {{.*}} nocapture)
|
||||
void test2(int *p0, int *p1) {
|
||||
auto t = [](int *, int * __attribute__((noescape))){};
|
||||
t(p0, p1);
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define void @_Z5test3PFvU8noescapePiES_(
|
||||
// CHECK: call void {{.*}}(i32* nocapture {{.*}})
|
||||
typedef void (*NoEscapeFunc)(__attribute__((noescape)) int *);
|
||||
|
||||
void test3(NoEscapeFunc f, int *p) {
|
||||
f(p);
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
// RUN: %clang_cc1 -triple x86_64-apple-darwin -fblocks -emit-llvm -o - %s | FileCheck %s
|
||||
|
||||
typedef void (^BlockTy)(void);
|
||||
|
||||
union U {
|
||||
int *i;
|
||||
long long *ll;
|
||||
} __attribute__((transparent_union));
|
||||
|
||||
void noescapeFunc0(id, __attribute__((noescape)) BlockTy);
|
||||
void noescapeFunc1(__attribute__((noescape)) int *);
|
||||
void noescapeFunc2(__attribute__((noescape)) id);
|
||||
void noescapeFunc3(__attribute__((noescape)) union U);
|
||||
|
||||
// CHECK-LABEL: define void @test0(
|
||||
// CHECK: call void @noescapeFunc0({{.*}}, {{.*}} nocapture {{.*}})
|
||||
// CHECK: declare void @noescapeFunc0(i8*, {{.*}} nocapture)
|
||||
void test0(BlockTy b) {
|
||||
noescapeFunc0(0, b);
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define void @test1(
|
||||
// CHECK: call void @noescapeFunc1({{.*}} nocapture {{.*}})
|
||||
// CHECK: declare void @noescapeFunc1({{.*}} nocapture)
|
||||
void test1(int *i) {
|
||||
noescapeFunc1(i);
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define void @test2(
|
||||
// CHECK: call void @noescapeFunc2({{.*}} nocapture {{.*}})
|
||||
// CHECK: declare void @noescapeFunc2({{.*}} nocapture)
|
||||
void test2(id i) {
|
||||
noescapeFunc2(i);
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define void @test3(
|
||||
// CHECK: call void @noescapeFunc3({{.*}} nocapture {{.*}})
|
||||
// CHECK: declare void @noescapeFunc3({{.*}} nocapture)
|
||||
void test3(union U u) {
|
||||
noescapeFunc3(u);
|
||||
}
|
||||
|
||||
// CHECK: define internal void @"\01-[C0 m0:]"({{.*}}, {{.*}}, {{.*}} nocapture {{.*}})
|
||||
|
||||
// CHECK-LABEL: define void @test4(
|
||||
// CHECK: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i32*)*)(i8* {{.*}}, i8* {{.*}}, i32* nocapture {{.*}})
|
||||
|
||||
@interface C0
|
||||
-(void) m0:(int*)__attribute__((noescape)) p0;
|
||||
@end
|
||||
|
||||
@implementation C0
|
||||
-(void) m0:(int*)__attribute__((noescape)) p0 {
|
||||
}
|
||||
@end
|
||||
|
||||
void test4(C0 *c0, int *p) {
|
||||
[c0 m0:p];
|
||||
}
|
||||
|
||||
// CHECK-LABEL: define void @test5(
|
||||
// CHECK: call void {{.*}}(i8* bitcast ({ i8**, i32, i32, i8*, {{.*}} }* @{{.*}} to i8*), i32* nocapture {{.*}})
|
||||
// CHECK: call void {{.*}}(i8* {{.*}}, i32* nocapture {{.*}})
|
||||
// CHECK: define internal void @{{.*}}(i8* {{.*}}, i32* nocapture {{.*}})
|
||||
|
||||
typedef void (^BlockTy2)(__attribute__((noescape)) int *);
|
||||
|
||||
void test5(BlockTy2 b, int *p) {
|
||||
^(int *__attribute__((noescape)) p0){}(p);
|
||||
b(p);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
|
||||
void escapefunc(int *);
|
||||
void noescapefunc(__attribute__((noescape)) int *);
|
||||
void (*escapefuncptr)(int *);
|
||||
void (*noescapefuncptr)(__attribute__((noescape)) int *);
|
||||
|
||||
void func_ne(__attribute__((noescape)) int *, int *);
|
||||
void func_en(int *, __attribute__((noescape)) int *);
|
||||
|
||||
void (*funcptr_ee)(int *, int *);
|
||||
void (*funcptr_nn)(__attribute__((noescape)) int *, __attribute__((noescape)) int *);
|
||||
|
||||
void test0(int c) {
|
||||
escapefuncptr = &escapefunc;
|
||||
escapefuncptr = &noescapefunc;
|
||||
noescapefuncptr = &escapefunc; // expected-warning {{incompatible function pointer types assigning to 'void (*)(__attribute__((noescape)) int *)' from 'void (*)(int *)'}}
|
||||
noescapefuncptr = &noescapefunc;
|
||||
|
||||
escapefuncptr = c ? &escapefunc : &noescapefunc;
|
||||
noescapefuncptr = c ? &escapefunc : &noescapefunc; // expected-warning {{incompatible function pointer types assigning to 'void (*)(__attribute__((noescape)) int *)' from 'void (*)(int *)'}}
|
||||
|
||||
funcptr_ee = c ? &func_ne : &func_en;
|
||||
funcptr_nn = c ? &func_ne : &func_en; // expected-warning {{incompatible function pointer types assigning to 'void (*)(__attribute__((noescape)) int *, __attribute__((noescape)) int *)' from 'void (*)(int *, int *)'}}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=c++11 %s
|
||||
// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=c++1z %s
|
||||
|
||||
typedef void (^BlockTy)();
|
||||
|
||||
struct S {
|
||||
int i;
|
||||
void m();
|
||||
};
|
||||
|
||||
void noescapeFunc0(id, __attribute__((noescape)) BlockTy);
|
||||
void noescapeFunc1(id, [[clang::noescape]] BlockTy);
|
||||
void noescapeFunc2(__attribute__((noescape)) int *); // expected-note {{previous declaration is here}}
|
||||
void noescapeFunc3(__attribute__((noescape)) id);
|
||||
void noescapeFunc4(__attribute__((noescape)) int &);
|
||||
void noescapeFunc2(int *); // expected-error {{conflicting types for 'noescapeFunc2'}}
|
||||
|
||||
void invalidFunc0(int __attribute__((noescape))); // expected-warning {{'noescape' attribute only applies to pointer arguments}}
|
||||
void invalidFunc1(int __attribute__((noescape(0)))); // expected-error {{'noescape' attribute takes no arguments}}
|
||||
void invalidFunc2(int0 *__attribute__((noescape))); // expected-error {{use of undeclared identifier 'int0'; did you mean 'int'?}}
|
||||
void invalidFunc3(__attribute__((noescape)) int (S::*Ty)); // expected-warning {{'noescape' attribute only applies to pointer arguments}}
|
||||
void invalidFunc4(__attribute__((noescape)) void (S::*Ty)()); // expected-warning {{'noescape' attribute only applies to pointer arguments}}
|
||||
int __attribute__((noescape)) g; // expected-warning {{'noescape' attribute only applies to parameters}}
|
||||
|
||||
struct S1 {
|
||||
virtual void m0(int *__attribute__((noescape))); // expected-note {{parameter of overridden method is annotated with __attribute__((noescape))}}
|
||||
};
|
||||
|
||||
struct S2 : S1 {
|
||||
void m0(int *__attribute__((noescape))) override;
|
||||
};
|
||||
|
||||
struct S3 : S1 {
|
||||
void m0(int *) override; // expected-warning {{parameter of overriding method should be annotated with __attribute__((noescape))}}
|
||||
};
|
||||
|
||||
__attribute__((objc_root_class))
|
||||
@interface C0
|
||||
-(void) m0:(int*)__attribute__((noescape)) p; // expected-note {{parameter of overridden method is annotated with __attribute__((noescape))}}
|
||||
@end
|
||||
|
||||
@implementation C0
|
||||
-(void) m0:(int*)__attribute__((noescape)) p {}
|
||||
@end
|
||||
|
||||
@interface C1 : C0
|
||||
-(void) m0:(int*)__attribute__((noescape)) p;
|
||||
@end
|
||||
|
||||
@implementation C1 : C0
|
||||
-(void) m0:(int*)__attribute__((noescape)) p {}
|
||||
@end
|
||||
|
||||
@interface C2 : C0
|
||||
-(void) m0:(int*) p; // expected-warning {{parameter of overriding method should be annotated with __attribute__((noescape))}}
|
||||
@end
|
||||
|
||||
@implementation C2 : C0
|
||||
-(void) m0:(int*) p {}
|
||||
@end
|
||||
|
||||
void func0(int *);
|
||||
void (*fnptr0)(int *);
|
||||
void (*fnptr1)(__attribute__((noescape)) int *);
|
||||
template<void (*fn)(int*)> struct S4 {};
|
||||
template<void (*fn)(int* __attribute__((noescape)))> struct S5 {};
|
||||
|
||||
#if __cplusplus < 201406
|
||||
// expected-note@-4 {{template parameter is declared here}}
|
||||
// expected-note@-4 {{template parameter is declared here}}
|
||||
#endif
|
||||
|
||||
void test0() {
|
||||
fnptr0 = &func0;
|
||||
fnptr0 = &noescapeFunc2;
|
||||
fnptr1 = &func0; // expected-error {{assigning to 'void (*)(__attribute__((noescape)) int *)' from incompatible type 'void (*)(int *)'}}
|
||||
fnptr1 = &noescapeFunc2;
|
||||
S4<&func0> e0;
|
||||
S4<&noescapeFunc2> e1;
|
||||
S5<&func0> ne0;
|
||||
|
||||
#if __cplusplus < 201406
|
||||
// expected-error@-4 {{non-type template argument of type 'void (*)(__attribute__((noescape)) int *)' cannot be converted to a value of type 'void (*)(int *)'}}
|
||||
// expected-error@-4 {{non-type template argument of type 'void (*)(int *)' cannot be converted to a value of type 'void (*)(__attribute__((noescape)) int *)'}}
|
||||
#else
|
||||
// expected-error@-6 {{value of type 'void (*)(int *)' is not implicitly convertible to 'void (*)(__attribute__((noescape)) int *)'}}
|
||||
#endif
|
||||
|
||||
S5<&noescapeFunc2> ne1;
|
||||
}
|
Loading…
Reference in New Issue