1 // RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm %s -triple x86_64-unknown-linux-gnu -o - | FileCheck %s
2
3 class A {
4 public:
5 [[clang::nomerge]] A();
6 [[clang::nomerge]] virtual ~A();
7 [[clang::nomerge]] void f();
8 [[clang::nomerge]] virtual void g();
9 [[clang::nomerge]] static void f1();
10 };
11
12 class B : public A {
13 public:
14 void g() override;
15 };
16
17 bool bar();
18 [[clang::nomerge]] void f(bool, bool);
19
foo(int i,A * ap,B * bp)20 void foo(int i, A *ap, B *bp) {
21 [[clang::nomerge]] bar();
22 [[clang::nomerge]] (i = 4, bar());
23 [[clang::nomerge]] (void)(bar());
24 f(bar(), bar());
25 [[clang::nomerge]] [] { bar(); bar(); }(); // nomerge only applies to the anonymous function call
26 [[clang::nomerge]] for (bar(); bar(); bar()) {}
27 [[clang::nomerge]] { asm("nop"); }
28 bar();
29
30 ap->g();
31 bp->g();
32
33 A a;
34 a.f();
35 a.g();
36 A::f1();
37
38 B b;
39 b.g();
40
41 A *newA = new B();
42 delete newA;
43 }
44
45 int g(int i);
46
something()47 void something() {
48 g(1);
49 }
50
51 [[clang::nomerge]] int g(int i);
52
something_else()53 void something_else() {
54 g(1);
55 }
56
g(int i)57 int g(int i) { return i; }
58
something_else_again()59 void something_else_again() {
60 g(1);
61 }
62
63 // CHECK: call noundef zeroext i1 @_Z3barv() #[[ATTR0:[0-9]+]]
64 // CHECK: call noundef zeroext i1 @_Z3barv() #[[ATTR0]]
65 // CHECK: call noundef zeroext i1 @_Z3barv() #[[ATTR0]]
66 // CHECK: call noundef zeroext i1 @_Z3barv(){{$}}
67 // CHECK: call noundef zeroext i1 @_Z3barv(){{$}}
68 // CHECK: call void @_Z1fbb({{.*}}) #[[ATTR0]]
69 // CHECK: call void @"_ZZ3fooiP1AP1BENK3$_0clEv"{{.*}} #[[ATTR0]]
70 // CHECK: call noundef zeroext i1 @_Z3barv() #[[ATTR0]]
71 // CHECK-LABEL: for.cond:
72 // CHECK: call noundef zeroext i1 @_Z3barv() #[[ATTR0]]
73 // CHECK-LABEL: for.inc:
74 // CHECK: call noundef zeroext i1 @_Z3barv() #[[ATTR0]]
75 // CHECK: call void asm sideeffect "nop"{{.*}} #[[ATTR1:[0-9]+]]
76 // CHECK: call noundef zeroext i1 @_Z3barv(){{$}}
77 // CHECK: %[[AG:.*]] = load void (%class.A*)*, void (%class.A*)**
78 // CHECK-NEXT: call void %[[AG]](%class.A* {{.*}}) #[[ATTR0]]
79 // CHECK: %[[BG:.*]] = load void (%class.B*)*, void (%class.B*)**
80 // CHECK-NEXT: call void %[[BG]](%class.B* noundef{{.*}}
81 // CHECK: call void @_ZN1AC1Ev({{.*}}) #[[ATTR0]]
82 // CHECK: call void @_ZN1A1fEv({{.*}}) #[[ATTR0]]
83 // CHECK: call void @_ZN1A1gEv({{.*}}) #[[ATTR0]]
84 // CHECK: call void @_ZN1A2f1Ev() #[[ATTR0]]
85 // CHECK: call void @_ZN1BC1Ev({{.*}}){{$}}
86 // CHECK: call void @_ZN1B1gEv({{.*}}){{$}}
87 // CHECK: call void @_ZN1BC1Ev({{.*}}){{$}}
88 // CHECK: %[[AG:.*]] = load void (%class.A*)*, void (%class.A*)**
89 // CHECK-NEXT: call void %[[AG]](%class.A* {{.*}}) #[[ATTR1]]
90 // CHECK: call void @_ZN1AD1Ev(%class.A* {{.*}}) #[[ATTR1]]
91
92 // CHECK-DAG: attributes #[[ATTR0]] = {{{.*}}nomerge{{.*}}}
93 // CHECK-DAG: attributes #[[ATTR1]] = {{{.*}}nomerge{{.*}}}
94