2012-10-02 17:09:43 +08:00
|
|
|
// RUN: rm -rf %t
|
2015-06-16 08:08:24 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -x objective-c++ -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs -verify %s -Wno-objc-root-class
|
|
|
|
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -x objective-c++ -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs -emit-llvm %s -o - -Wno-objc-root-class | FileCheck %s
|
2012-10-19 20:44:48 +08:00
|
|
|
// expected-no-diagnostics
|
2015-07-08 09:00:30 +08:00
|
|
|
// REQUIRES: x86-registered-target
|
2012-12-12 06:11:52 +08:00
|
|
|
@import templates_left;
|
2014-05-29 11:15:31 +08:00
|
|
|
|
|
|
|
void testInlineRedeclEarly() {
|
|
|
|
// instantiate definition now, we'll add another declaration in _right.
|
|
|
|
OutOfLineInline<int>().h();
|
|
|
|
}
|
|
|
|
|
2012-12-12 06:11:52 +08:00
|
|
|
@import templates_right;
|
2012-10-02 17:09:43 +08:00
|
|
|
|
2016-07-21 03:10:16 +08:00
|
|
|
// CHECK-DAG: @list_left = global %[[LIST:.*]] { %[[LISTNODE:.*]]* null, i32 8 }, align 8
|
|
|
|
// CHECK-DAG: @list_right = global %[[LIST]] { %[[LISTNODE]]* null, i32 12 }, align 8
|
|
|
|
// CHECK-DAG: @_ZZ15testMixedStructvE1l = {{.*}} constant %[[LIST]] { %{{.*}}* null, i32 1 }, align 8
|
|
|
|
// CHECK-DAG: @_ZZ15testMixedStructvE1r = {{.*}} constant %[[LIST]] { %{{.*}}* null, i32 2 }, align 8
|
2014-09-03 10:33:22 +08:00
|
|
|
// CHECK-DAG: @_ZN29WithUndefinedStaticDataMemberIA_iE9undefinedE = external global
|
2012-10-02 17:09:43 +08:00
|
|
|
|
|
|
|
void testTemplateClasses() {
|
|
|
|
Vector<int> vec_int;
|
|
|
|
vec_int.push_back(0);
|
|
|
|
|
|
|
|
List<bool> list_bool;
|
|
|
|
list_bool.push_back(false);
|
|
|
|
|
|
|
|
N::Set<char> set_char;
|
|
|
|
set_char.insert('A');
|
2014-04-19 11:48:30 +08:00
|
|
|
|
2015-08-12 06:00:24 +08:00
|
|
|
static_assert(sizeof(List<long>) == sizeof(List<short>), "");
|
|
|
|
|
2014-04-19 11:48:30 +08:00
|
|
|
List<double> list_double;
|
|
|
|
list_double.push_back(0.0);
|
2012-10-02 17:09:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void testPendingInstantiations() {
|
2012-10-02 20:18:46 +08:00
|
|
|
// CHECK: call {{.*pendingInstantiationEmit}}
|
|
|
|
// CHECK: call {{.*pendingInstantiationEmit}}
|
|
|
|
// CHECK: define {{.*pendingInstantiationEmit.*[(]i}}
|
|
|
|
// CHECK: define {{.*pendingInstantiationEmit.*[(]double}}
|
2012-10-02 17:09:43 +08:00
|
|
|
triggerPendingInstantiation();
|
|
|
|
triggerPendingInstantiationToo();
|
|
|
|
}
|
2012-10-02 20:18:46 +08:00
|
|
|
|
|
|
|
void testRedeclDefinition() {
|
|
|
|
// CHECK: define {{.*redeclDefinitionEmit}}
|
|
|
|
redeclDefinitionEmit();
|
|
|
|
}
|
|
|
|
|
2014-05-29 11:15:31 +08:00
|
|
|
void testInlineRedecl() {
|
|
|
|
outOfLineInlineUseLeftF();
|
|
|
|
outOfLineInlineUseRightG();
|
|
|
|
|
|
|
|
outOfLineInlineUseRightF();
|
|
|
|
outOfLineInlineUseLeftG();
|
|
|
|
}
|
|
|
|
|
2014-04-25 06:45:46 +08:00
|
|
|
// CHECK-NOT: @_ZN21ExplicitInstantiationILb0ELb0EE1fEv(
|
|
|
|
// CHECK: declare {{.*}}@_ZN21ExplicitInstantiationILb1ELb0EE1fEv(
|
|
|
|
// CHECK: define {{.*}}@_ZN21ExplicitInstantiationILb1ELb1EE1fEv(
|
|
|
|
// CHECK-NOT: @_ZN21ExplicitInstantiationILb0ELb0EE1fEv(
|
|
|
|
|
2013-09-10 00:55:27 +08:00
|
|
|
// These three are all the same type.
|
|
|
|
typedef OuterIntInner_left OuterIntInner;
|
|
|
|
typedef OuterIntInner_right OuterIntInner;
|
|
|
|
typedef Outer<int>::Inner OuterIntInner;
|
|
|
|
|
2012-10-02 20:18:46 +08:00
|
|
|
// CHECK: call {{.*pendingInstantiation}}
|
|
|
|
// CHECK: call {{.*redeclDefinitionEmit}}
|
2013-10-07 16:02:11 +08:00
|
|
|
|
|
|
|
static_assert(size_left == size_right, "same field both ways");
|
|
|
|
void useListInt(List<int> &);
|
|
|
|
|
|
|
|
// CHECK-LABEL: define i32 @_Z15testMixedStructv(
|
|
|
|
unsigned testMixedStruct() {
|
|
|
|
// CHECK: %[[l:.*]] = alloca %[[ListInt:[^ ]*]], align 8
|
|
|
|
// CHECK: %[[r:.*]] = alloca %[[ListInt]], align 8
|
|
|
|
|
Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Summary:
Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the Clang tests for this change.
The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.
This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)
At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.
llvm-svn: 322964
2018-01-20 01:12:54 +08:00
|
|
|
// CHECK: call {{.*}}memcpy{{.*}}(i8* align {{[0-9]+}} %{{.*}}, i8* align {{[0-9]+}} bitcast ({{.*}}* @_ZZ15testMixedStructvE1l to i8*), i64 16,
|
2013-10-07 16:02:11 +08:00
|
|
|
ListInt_left l{0, 1};
|
|
|
|
|
Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Summary:
Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the Clang tests for this change.
The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.
This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.
For example, code which used to read:
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)
At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.
llvm-svn: 322964
2018-01-20 01:12:54 +08:00
|
|
|
// CHECK: call {{.*}}memcpy{{.*}}(i8* align {{[0-9]+}} %{{.*}}, i8* align {{[0-9]+}} bitcast ({{.*}}* @_ZZ15testMixedStructvE1r to i8*), i64 16,
|
2013-10-07 16:02:11 +08:00
|
|
|
ListInt_right r{0, 2};
|
|
|
|
|
2014-07-18 23:52:10 +08:00
|
|
|
// CHECK: call void @_Z10useListIntR4ListIiE(%[[ListInt]]* dereferenceable({{[0-9]+}}) %[[l]])
|
2013-10-07 16:02:11 +08:00
|
|
|
useListInt(l);
|
2014-07-18 23:52:10 +08:00
|
|
|
// CHECK: call void @_Z10useListIntR4ListIiE(%[[ListInt]]* dereferenceable({{[0-9]+}}) %[[r]])
|
2013-10-07 16:02:11 +08:00
|
|
|
useListInt(r);
|
|
|
|
|
2015-03-14 02:21:46 +08:00
|
|
|
// CHECK: load i32, i32* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @list_left to i8*), i64 8) to i32*)
|
|
|
|
// CHECK: load i32, i32* bitcast (i8* getelementptr inbounds (i8, i8* bitcast ({{.*}}* @list_right to i8*), i64 8) to i32*)
|
2013-10-07 16:02:11 +08:00
|
|
|
return list_left.*size_right + list_right.*size_left;
|
|
|
|
}
|
2014-04-24 10:25:27 +08:00
|
|
|
|
|
|
|
template<typename T> struct MergePatternDecl {
|
|
|
|
typedef int Type;
|
|
|
|
void f(Type);
|
|
|
|
};
|
|
|
|
template<typename T> void MergePatternDecl<T>::f(Type type) {}
|
2014-04-25 06:45:46 +08:00
|
|
|
// CHECK: define {{.*}}@_ZN21ExplicitInstantiationILb0ELb1EE1fEv(
|
|
|
|
template struct ExplicitInstantiation<false, true>;
|
|
|
|
template struct ExplicitInstantiation<true, true>;
|
2014-04-30 10:24:17 +08:00
|
|
|
|
|
|
|
void testDelayUpdatesImpl() { testDelayUpdates<int>(); }
|
2014-09-03 10:33:22 +08:00
|
|
|
|
|
|
|
void testStaticDataMember() {
|
|
|
|
WithUndefinedStaticDataMember<int[]> load_it;
|
|
|
|
|
|
|
|
// CHECK-LABEL: define linkonce_odr i32* @_Z23getStaticDataMemberLeftv(
|
2015-03-14 02:21:46 +08:00
|
|
|
// CHECK: ret i32* getelementptr inbounds ([0 x i32], [0 x i32]* @_ZN29WithUndefinedStaticDataMemberIA_iE9undefinedE, i32 0, i32 0)
|
2014-09-03 10:33:22 +08:00
|
|
|
(void) getStaticDataMemberLeft();
|
|
|
|
|
|
|
|
// CHECK-LABEL: define linkonce_odr i32* @_Z24getStaticDataMemberRightv(
|
2015-03-14 02:21:46 +08:00
|
|
|
// CHECK: ret i32* getelementptr inbounds ([0 x i32], [0 x i32]* @_ZN29WithUndefinedStaticDataMemberIA_iE9undefinedE, i32 0, i32 0)
|
2014-09-03 10:33:22 +08:00
|
|
|
(void) getStaticDataMemberRight();
|
|
|
|
}
|
|
|
|
|
2016-10-26 10:31:56 +08:00
|
|
|
void testWithAttributes() {
|
|
|
|
auto a = make_with_attributes_left();
|
|
|
|
auto b = make_with_attributes_right();
|
|
|
|
static_assert(alignof(decltype(a)) == 2, "");
|
|
|
|
static_assert(alignof(decltype(b)) == 2, "");
|
|
|
|
}
|
2018-03-20 01:38:40 +08:00
|
|
|
|
|
|
|
// Check that returnNonTrivial doesn't return Class0<S0> directly in registers.
|
|
|
|
|
|
|
|
// CHECK: declare void @_Z16returnNonTrivialv(%struct.Class0* sret)
|
|
|
|
|
|
|
|
@import template_nontrivial0;
|
|
|
|
@import template_nontrivial1;
|
|
|
|
|
|
|
|
S1::S1() : a(returnNonTrivial()) {
|
|
|
|
}
|