annotate clang/test/CodeGenCXX/assign-operator.cpp @ 206:f17a3b42b08b

Added tag before-12 for changeset b7591485f4cd
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 07 Jun 2021 21:25:57 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - -std=c++11 |FileCheck %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 class x {
anatofuz
parents:
diff changeset
4 public: int operator=(int);
anatofuz
parents:
diff changeset
5 };
anatofuz
parents:
diff changeset
6 void a() {
anatofuz
parents:
diff changeset
7 x a;
anatofuz
parents:
diff changeset
8 a = 1u;
anatofuz
parents:
diff changeset
9 }
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 void f(int i, int j) {
anatofuz
parents:
diff changeset
12 // CHECK: load i32
anatofuz
parents:
diff changeset
13 // CHECK: load i32
anatofuz
parents:
diff changeset
14 // CHECK: add nsw i32
anatofuz
parents:
diff changeset
15 // CHECK: store i32
anatofuz
parents:
diff changeset
16 // CHECK: store i32 17, i32
anatofuz
parents:
diff changeset
17 // CHECK: ret
anatofuz
parents:
diff changeset
18 (i += j) = 17;
anatofuz
parents:
diff changeset
19 }
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 // Taken from g++.old-deja/g++.jason/net.C
anatofuz
parents:
diff changeset
22 namespace test1 {
anatofuz
parents:
diff changeset
23 template <class T> void fn (T t) { }
anatofuz
parents:
diff changeset
24 template <class T> struct A {
anatofuz
parents:
diff changeset
25 void (*p)(T);
anatofuz
parents:
diff changeset
26 A() { p = fn; }
anatofuz
parents:
diff changeset
27 };
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 A<int> a;
anatofuz
parents:
diff changeset
30 }
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 // Ensure that we use memcpy when we would have selected a trivial assignment
anatofuz
parents:
diff changeset
33 // operator, even for a non-trivially-copyable type.
anatofuz
parents:
diff changeset
34 struct A {
anatofuz
parents:
diff changeset
35 A &operator=(const A&);
anatofuz
parents:
diff changeset
36 };
anatofuz
parents:
diff changeset
37 struct B {
anatofuz
parents:
diff changeset
38 B(const B&);
anatofuz
parents:
diff changeset
39 B &operator=(const B&) = default;
anatofuz
parents:
diff changeset
40 int n;
anatofuz
parents:
diff changeset
41 };
anatofuz
parents:
diff changeset
42 struct C {
anatofuz
parents:
diff changeset
43 A a;
anatofuz
parents:
diff changeset
44 B b[16];
anatofuz
parents:
diff changeset
45 };
anatofuz
parents:
diff changeset
46 void b(C &a, C &b) {
anatofuz
parents:
diff changeset
47 // CHECK: define {{.*}} @_ZN1CaSERKS_(
anatofuz
parents:
diff changeset
48 // CHECK: call {{.*}} @_ZN1AaSERKS_(
anatofuz
parents:
diff changeset
49 // CHECK-NOT: call {{.*}} @_ZN1BaSERKS_(
anatofuz
parents:
diff changeset
50 // CHECK: call {{.*}} @{{.*}}memcpy
anatofuz
parents:
diff changeset
51 // CHECK-NOT: call {{.*}} @_ZN1BaSERKS_(
anatofuz
parents:
diff changeset
52 // CHECK: }
anatofuz
parents:
diff changeset
53 a = b;
anatofuz
parents:
diff changeset
54 }