332 lines · cpp
1// RUN: %clang_cc1 -w -debug-info-kind=line-tables-only -std=c++11 -fexceptions -fcxx-exceptions -mllvm -no-discriminators -emit-llvm %s -o - -triple %itanium_abi_triple | FileCheck %s2// RUN: %clang_cc1 -w -debug-info-kind=line-tables-only -std=c++11 -fexceptions -fcxx-exceptions -mllvm -no-discriminators -emit-llvm %s -o - -triple i686-linux-gnu | FileCheck %s3// RUN: %clang_cc1 -w -debug-info-kind=line-directives-only -std=c++11 -fexceptions -fcxx-exceptions -mllvm -no-discriminators -emit-llvm %s -o - -triple %itanium_abi_triple | FileCheck %s4// RUN: %clang_cc1 -w -debug-info-kind=line-directives-only -std=c++11 -fexceptions -fcxx-exceptions -mllvm -no-discriminators -emit-llvm %s -o - -triple i686-linux-gnu | FileCheck %s5 6int &src();7int *sink();8extern "C" __complex float complex_src();9extern "C" __complex float *complex_sink();10 11// CHECK-LABEL: define12void f1() {13 *sink()14 // CHECK: store {{.*}}, !dbg [[DBG_F1:!.*]]15#line 10016 = //17 src();18}19 20struct foo {21 int i;22 int &j;23 __complex float k;24 foo();25};26 27// CHECK-LABEL: define28foo::foo()29 :30#line 20031 i // CHECK: store i32 {{.*}} !dbg [[DBG_FOO_VALUE:!.*]]32 (src()),33 j // CHECK: store ptr {{.*}} !dbg [[DBG_FOO_REF:!.*]]34 (src()),35 k // CHECK: store float {{.*}} !dbg [[DBG_FOO_COMPLEX:!.*]]36 (complex_src()) {37}38 39// CHECK-LABEL: define {{.*}}f2{{.*}}40void f2() {41 // CHECK: store float {{.*}} !dbg [[DBG_F2:!.*]]42 *complex_sink()43#line 30044 = //45 complex_src();46}47 48// CHECK-LABEL: define49void f3() {50 // CHECK: store float {{.*}} !dbg [[DBG_F3:!.*]]51 *complex_sink()52#line 40053 += //54 complex_src();55}56 57// CHECK-LABEL: define58void f4() {59#line 50060 auto x // CHECK: store {{.*}} !dbg [[DBG_F4:!.*]]61 = src();62}63 64// CHECK-LABEL: define65void f5() {66#line 60067 auto x // CHECK: store float {{.*}} !dbg [[DBG_F5:!.*]]68 = complex_src();69}70 71struct agg { int i; };72agg agg_src();73 74// CHECK-LABEL: define75void f6() {76 agg x;77 // CHECK: call void @llvm.memcpy{{.*}} !dbg [[DBG_F6:!.*]]78 x79#line 70080 = //81 agg_src();82}83 84// CHECK-LABEL: define85void f7() {86 int *src1();87 int src2();88#line 80089 int x = ( // CHECK: load {{.*}} !dbg [[DBG_F7:!.*]]90 src1())[src2()];91}92 93// CHECK-LABEL: define94void f8() {95 int src1[1];96 int src2();97#line 90098 int x = ( // CHECK: load {{.*}} !dbg [[DBG_F8:!.*]]99 src1)[src2()];100}101 102// CHECK-LABEL: define103void f9(int i) {104 int src1[1][i];105 int src2();106#line 1000107 auto x = ( // CHECK: getelementptr {{.*}} !dbg [[DBG_F9:!.*]]108 src1)[src2()];109}110 111inline void *operator new(decltype(sizeof(1)), void *p) noexcept { return p; }112 113// CHECK-LABEL: define114void f10() {115 void *void_src();116 (117 // CHECK: store {{.*}} !dbg [[DBG_F10_STORE:!.*]]118#line 1100119 new (void_src()) int(src()));120}121 122// noexcept just to simplify the codegen a bit123void fn() noexcept(true);124 125struct bar {126 bar();127 // noexcept(false) to convolute the global dtor128 ~bar() noexcept(false);129};130// global ctor cleanup131// CHECK-LABEL: define132// CHECK: invoke{{ }}133// CHECK: invoke{{ }}134// CHECK: to label {{.*}}, !dbg [[DBG_GLBL_CTOR_B:!.*]]135 136// terminate caller137// CHECK-LABEL: define138 139// global dtor cleanup140// CHECK-LABEL: define141// CHECK: invoke{{ }}142// CHECK: invoke{{ }}143// CHECK: to label {{.*}}, !dbg [[DBG_GLBL_DTOR_B:!.*]]144#line 1200145bar b[1] = { //146 (fn(), //147 bar())};148 149// CHECK-LABEL: define{{.*}}f11150__complex double f11() {151 __complex double f;152// CHECK: store {{.*}} !dbg [[DBG_F11:!.*]]153#line 1300154 return f;155}156 157// CHECK-LABEL: define158void f12() {159 int f12_1();160 void f12_2(int = f12_1());161// CHECK: call {{.*}}{{(signext )?}}i32 noundef {{.*}} !dbg [[DBG_F12:!.*]]162#line 1400163 f12_2();164}165 166// CHECK-LABEL: define167void f13() {168// CHECK: call {{.*}} !dbg [[DBG_F13:!.*]]169#define F13_IMPL 1, src()170 1,171#line 1500172 F13_IMPL;173}174 175struct f14_impl {176 f14_impl(int);177};178 179// CHECK-LABEL: define180struct f14_use {181// CHECK: call {{.*}}f14_impl{{.*}}, !dbg [[DBG_F14_CTOR_CALL:![0-9]*]]182#line 1600183 f14_impl v{//184 1};185 f14_use();186};187 188f14_use::f14_use() = default;189 190// CHECK-LABEL: define191// CHECK-LABEL: define192void func(foo);193void f15(foo *f) {194 func(195// CHECK: getelementptr {{.*}}, !dbg [[DBG_F15:![0-9]*]]196#line 1700197 f[3]);198}199 200// CHECK-LABEL: define201void f16(__complex float f) {202 __complex float g = //203// CHECK: add {{.*}}, !dbg [[DBG_F16:![0-9]*]]204#line 1800205 f + 1;206}207 208// CHECK-LABEL: define209void f17(int *x) {210 1,211// CHECK: getelementptr {{.*}}, !dbg [[DBG_F17:![0-9]*]]212#line 1900213 x[1];214}215 216// CHECK-LABEL: define217void f18(int a, int b) {218// CHECK: icmp {{.*}}, !dbg [[DBG_F18_1:![0-9]*]]219// CHECK: br {{.*}}, !dbg [[DBG_F18_2:![0-9]*]]220#line 2000221 if (a //222 && //223 b)224 ;225}226 227// CHECK-LABEL: define228void f19(int a, int b) {229// CHECK: icmp {{.*}}, !dbg [[DBG_F19_1:![0-9]*]]230// CHECK: br {{.*}}, !dbg [[DBG_F19_2:![0-9]*]]231#line 2100232 if (a //233 || //234 b)235 ;236}237 238// CHECK-LABEL: define239void f20(int a, int b, int c) {240// CHECK: icmp {{.*}}, !dbg [[DBG_F20_1:![0-9]*]]241// FIXME: Conditional operator's exprloc should be the '?' not the start of the242// expression, then this would go in the right place. (but adding getExprLoc to243// the ConditionalOperator breaks the ARC migration tool - need to investigate244// further).245// CHECK: br {{.*}}, !dbg [[DBG_F20_1]]246#line 2200247 if (a //248 ? //249 b : c)250 ;251}252 253// CHECK-LABEL: define254int f21_a(int = 0);255void f21_b(int = f21_a());256void f21() {257// CHECK: call {{.*}}f21_b{{.*}}, !dbg [[DBG_F21:![0-9]*]]258#line 2300259 f21_b();260}261 262// CHECK-LABEL: define263struct f22_dtor {264 ~f22_dtor();265};266void f22() {267 {268 f22_dtor f;269 src();270// CHECK: invoke {{.*}}src271// CHECK: call {{.*}}, !dbg [[DBG_F22:![0-9]*]]272// CHECK: call {{.*}}, !dbg [[DBG_F22]]273#line 2400274 }275}276 277// CHECK-LABEL: define278struct f23_struct {279};280f23_struct f23_a();281void f23_b(f23_struct = f23_a());282void f23() {283// CHECK: call {{.*}}f23_a{{.*}}, !dbg [[DBG_F23:![0-9]*]]284#line 2500285 f23_b();286}287 288// CHECK-LABEL: define289void f24_a(__complex float = complex_src());290void f24() {291// CHECK: call {{.*}}complex_src{{.*}}, !dbg [[DBG_F24:![0-9]*]]292#line 2600293 f24_a();294}295 296// CHECK-LABEL: define297void f25_a(int x = __builtin_LINE()) {}298void f25() {299 // CHECK: call void @_Z5f25_ai(i32 noundef {{(signext )?}}2700)300#line 2700301 f25_a();302}303// CHECK: [[DBG_F1]] = !DILocation(line: 100,304// CHECK: [[DBG_FOO_VALUE]] = !DILocation(line: 200,305// CHECK: [[DBG_FOO_REF]] = !DILocation(line: 202,306// CHECK: [[DBG_FOO_COMPLEX]] = !DILocation(line: 204,307// CHECK: [[DBG_F2]] = !DILocation(line: 300,308// CHECK: [[DBG_F3]] = !DILocation(line: 400,309// CHECK: [[DBG_F4]] = !DILocation(line: 500,310// CHECK: [[DBG_F5]] = !DILocation(line: 600,311// CHECK: [[DBG_F6]] = !DILocation(line: 700,312// CHECK: [[DBG_F7]] = !DILocation(line: 800,313// CHECK: [[DBG_F8]] = !DILocation(line: 900,314// CHECK: [[DBG_F9]] = !DILocation(line: 1000,315// CHECK: [[DBG_F10_STORE]] = !DILocation(line: 1100,316// CHECK: [[DBG_GLBL_CTOR_B]] = !DILocation(line: 1200,317// CHECK: [[DBG_GLBL_DTOR_B]] = !DILocation(line: 0,318// CHECK: [[DBG_F11]] = !DILocation(line: 1300,319// CHECK: [[DBG_F12]] = !DILocation(line: 1400,320// CHECK: [[DBG_F13]] = !DILocation(line: 1500,321// CHECK: [[DBG_F14_CTOR_CALL]] = !DILocation(line: 1600,322// CHECK: [[DBG_F15]] = !DILocation(line: 1700,323// CHECK: [[DBG_F16]] = !DILocation(line: 1800,324// CHECK: [[DBG_F17]] = !DILocation(line: 1900,325// CHECK: [[DBG_F18_1]] = !DILocation(line: 2000,326// CHECK: [[DBG_F18_2]] = !DILocation(line: 2001,327// CHECK: [[DBG_F19_1]] = !DILocation(line: 2100,328// CHECK: [[DBG_F19_2]] = !DILocation(line: 2101,329// CHECK: [[DBG_F20_1]] = !DILocation(line: 2200,330// CHECK: [[DBG_F23]] = !DILocation(line: 2500,331// CHECK: [[DBG_F24]] = !DILocation(line: 2600,332