1 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -std=c++11 | FileCheck %s 2 3 namespace PR16263 { 4 const unsigned int n = 1234; 5 extern const int &r = (const int&)n; 6 // CHECK: @_ZGRN7PR162631rE = private constant i32 1234, 7 // CHECK: @_ZN7PR162631rE = constant i32* @_ZGRN7PR162631rE, 8 9 extern const int &s = reinterpret_cast<const int&>(n); 10 // CHECK: @_ZN7PR16263L1nE = internal constant i32 1234, align 4 11 // CHECK: @_ZN7PR162631sE = constant i32* @_ZN7PR16263L1nE, align 8 12 13 struct A { int n; }; 14 struct B { int n; }; 15 struct C : A, B {}; 16 extern const A &&a = (A&&)(A&&)(C&&)(C{}); 17 // CHECK: @_ZGRN7PR162631aE = private global {{.*}} zeroinitializer, 18 // CHECK: @_ZN7PR162631aE = constant {{.*}} bitcast ({{.*}}* @_ZGRN7PR162631aE to 19 20 extern const int &&t = ((B&&)C{}).n; 21 // CHECK: @_ZGRN7PR162631tE = private global {{.*}} zeroinitializer, 22 // CHECK: @_ZN7PR162631tE = constant i32* {{.*}}* @_ZGRN7PR162631tE {{.*}} 4 23 24 struct D { double d; C c; }; 25 extern const int &&u = (123, static_cast<B&&>(0, ((D&&)D{}).*&D::c).n); 26 // CHECK: @_ZGRN7PR162631uE = private global {{.*}} zeroinitializer 27 // CHECK: @_ZN7PR162631uE = constant i32* {{.*}} @_ZGRN7PR162631uE {{.*}} 12 28 } 29 30 struct A { 31 A(); 32 ~A(); 33 void f(); 34 }; 35 36 void f1() { 37 // CHECK: call void @_ZN1AC1Ev 38 // CHECK: call void @_ZN1AD1Ev 39 (void)A(); 40 41 // CHECK: call void @_ZN1AC1Ev 42 // CHECK: call void @_ZN1AD1Ev 43 A().f(); 44 } 45 46 // Function calls 47 struct B { 48 B(); 49 ~B(); 50 }; 51 52 B g(); 53 54 void f2() { 55 // CHECK-NOT: call void @_ZN1BC1Ev 56 // CHECK: call void @_ZN1BD1Ev 57 (void)g(); 58 } 59 60 // Member function calls 61 struct C { 62 C(); 63 ~C(); 64 65 C f(); 66 }; 67 68 void f3() { 69 // CHECK: call void @_ZN1CC1Ev 70 // CHECK: call void @_ZN1CD1Ev 71 // CHECK: call void @_ZN1CD1Ev 72 C().f(); 73 } 74 75 // Function call operator 76 struct D { 77 D(); 78 ~D(); 79 80 D operator()(); 81 }; 82 83 void f4() { 84 // CHECK: call void @_ZN1DC1Ev 85 // CHECK: call void @_ZN1DD1Ev 86 // CHECK: call void @_ZN1DD1Ev 87 D()(); 88 } 89 90 // Overloaded operators 91 struct E { 92 E(); 93 ~E(); 94 E operator+(const E&); 95 E operator!(); 96 }; 97 98 void f5() { 99 // CHECK: call void @_ZN1EC1Ev 100 // CHECK: call void @_ZN1EC1Ev 101 // CHECK: call void @_ZN1ED1Ev 102 // CHECK: call void @_ZN1ED1Ev 103 // CHECK: call void @_ZN1ED1Ev 104 E() + E(); 105 106 // CHECK: call void @_ZN1EC1Ev 107 // CHECK: call void @_ZN1ED1Ev 108 // CHECK: call void @_ZN1ED1Ev 109 !E(); 110 } 111 112 struct F { 113 F(); 114 ~F(); 115 F& f(); 116 }; 117 118 void f6() { 119 // CHECK: call void @_ZN1FC1Ev 120 // CHECK: call void @_ZN1FD1Ev 121 F().f(); 122 } 123 124 struct G { 125 G(); 126 G(A); 127 ~G(); 128 operator A(); 129 }; 130 131 void a(const A&); 132 133 void f7() { 134 // CHECK: call void @_ZN1AC1Ev 135 // CHECK: call void @_Z1aRK1A 136 // CHECK: call void @_ZN1AD1Ev 137 a(A()); 138 139 // CHECK: call void @_ZN1GC1Ev 140 // CHECK: call void @_ZN1Gcv1AEv 141 // CHECK: call void @_Z1aRK1A 142 // CHECK: call void @_ZN1AD1Ev 143 // CHECK: call void @_ZN1GD1Ev 144 a(G()); 145 } 146 147 namespace PR5077 { 148 149 struct A { 150 A(); 151 ~A(); 152 int f(); 153 }; 154 155 void f(); 156 int g(const A&); 157 158 struct B { 159 int a1; 160 int a2; 161 B(); 162 ~B(); 163 }; 164 165 B::B() 166 // CHECK: call void @_ZN6PR50771AC1Ev 167 // CHECK: call i32 @_ZN6PR50771A1fEv 168 // CHECK: call void @_ZN6PR50771AD1Ev 169 : a1(A().f()) 170 // CHECK: call void @_ZN6PR50771AC1Ev 171 // CHECK: call i32 @_ZN6PR50771gERKNS_1AE 172 // CHECK: call void @_ZN6PR50771AD1Ev 173 , a2(g(A())) 174 { 175 // CHECK: call void @_ZN6PR50771fEv 176 f(); 177 } 178 179 struct C { 180 C(); 181 182 const B& b; 183 }; 184 185 C::C() 186 // CHECK: call void @_ZN6PR50771BC1Ev 187 : b(B()) { 188 // CHECK: call void @_ZN6PR50771fEv 189 f(); 190 191 // CHECK: call void @_ZN6PR50771BD1Ev 192 } 193 } 194 195 A f8() { 196 // CHECK: call void @_ZN1AC1Ev 197 // CHECK-NOT: call void @_ZN1AD1Ev 198 return A(); 199 // CHECK: ret void 200 } 201 202 struct H { 203 H(); 204 ~H(); 205 H(const H&); 206 }; 207 208 void f9(H h) { 209 // CHECK: call void @_ZN1HC1Ev 210 // CHECK: call void @_Z2f91H 211 // CHECK: call void @_ZN1HD1Ev 212 f9(H()); 213 214 // CHECK: call void @_ZN1HC1ERKS_ 215 // CHECK: call void @_Z2f91H 216 // CHECK: call void @_ZN1HD1Ev 217 f9(h); 218 } 219 220 void f10(const H&); 221 222 void f11(H h) { 223 // CHECK: call void @_ZN1HC1Ev 224 // CHECK: call void @_Z3f10RK1H 225 // CHECK: call void @_ZN1HD1Ev 226 f10(H()); 227 228 // CHECK: call void @_Z3f10RK1H 229 // CHECK-NOT: call void @_ZN1HD1Ev 230 // CHECK: ret void 231 f10(h); 232 } 233 234 // PR5808 235 struct I { 236 I(const char *); 237 ~I(); 238 }; 239 240 // CHECK: _Z3f12v 241 I f12() { 242 // CHECK: call void @_ZN1IC1EPKc 243 // CHECK-NOT: call void @_ZN1ID1Ev 244 // CHECK: ret void 245 return "Hello"; 246 } 247 248 // PR5867 249 namespace PR5867 { 250 struct S { 251 S(); 252 S(const S &); 253 ~S(); 254 }; 255 256 void f(S, int); 257 // CHECK: define void @_ZN6PR58671gEv 258 void g() { 259 // CHECK: call void @_ZN6PR58671SC1Ev 260 // CHECK-NEXT: call void @_ZN6PR58671fENS_1SEi 261 // CHECK-NEXT: call void @_ZN6PR58671SD1Ev 262 // CHECK-NEXT: ret void 263 (f)(S(), 0); 264 } 265 266 // CHECK: define linkonce_odr void @_ZN6PR58672g2IiEEvT_ 267 template<typename T> 268 void g2(T) { 269 // CHECK: call void @_ZN6PR58671SC1Ev 270 // CHECK-NEXT: call void @_ZN6PR58671fENS_1SEi 271 // CHECK-NEXT: call void @_ZN6PR58671SD1Ev 272 // CHECK-NEXT: ret void 273 (f)(S(), 0); 274 } 275 276 void h() { 277 g2(17); 278 } 279 } 280 281 // PR6199 282 namespace PR6199 { 283 struct A { ~A(); }; 284 285 struct B { operator A(); }; 286 287 // CHECK: define weak_odr void @_ZN6PR61992f2IiEENS_1AET_ 288 template<typename T> A f2(T) { 289 B b; 290 // CHECK: call void @_ZN6PR61991BcvNS_1AEEv 291 // CHECK-NEXT: ret void 292 return b; 293 } 294 295 template A f2<int>(int); 296 297 } 298 299 namespace T12 { 300 301 struct A { 302 A(); 303 ~A(); 304 int f(); 305 }; 306 307 int& f(int); 308 309 // CHECK: define void @_ZN3T121gEv 310 void g() { 311 // CHECK: call void @_ZN3T121AC1Ev 312 // CHECK-NEXT: call i32 @_ZN3T121A1fEv( 313 // CHECK-NEXT: call i32* @_ZN3T121fEi( 314 // CHECK-NEXT: call void @_ZN3T121AD1Ev( 315 int& i = f(A().f()); 316 } 317 318 } 319 320 namespace PR6648 { 321 struct B { 322 ~B(); 323 }; 324 B foo; 325 struct D; 326 D& zed(B); 327 void foobar() { 328 // CHECK: call %"struct.PR6648::D"* @_ZN6PR66483zedENS_1BE 329 zed(foo); 330 } 331 } 332 333 namespace UserConvertToValue { 334 struct X { 335 X(int); 336 X(const X&); 337 ~X(); 338 }; 339 340 void f(X); 341 342 // CHECK: void @_ZN18UserConvertToValue1gEv() 343 void g() { 344 // CHECK: call void @_ZN18UserConvertToValue1XC1Ei 345 // CHECK: call void @_ZN18UserConvertToValue1fENS_1XE 346 // CHECK: call void @_ZN18UserConvertToValue1XD1Ev 347 // CHECK: ret void 348 f(1); 349 } 350 } 351 352 namespace PR7556 { 353 struct A { ~A(); }; 354 struct B { int i; ~B(); }; 355 struct C { int C::*pm; ~C(); }; 356 // CHECK: define void @_ZN6PR75563fooEv() 357 void foo() { 358 // CHECK: call void @_ZN6PR75561AD1Ev 359 A(); 360 // CHECK: call void @llvm.memset.p0i8.i64 361 // CHECK: call void @_ZN6PR75561BD1Ev 362 B(); 363 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64 364 // CHECK: call void @_ZN6PR75561CD1Ev 365 C(); 366 // CHECK-NEXT: ret void 367 } 368 } 369 370 namespace Elision { 371 struct A { 372 A(); A(const A &); ~A(); 373 void *p; 374 void foo() const; 375 }; 376 377 void foo(); 378 A fooA(); 379 void takeA(A a); 380 381 // CHECK: define void @_ZN7Elision5test0Ev() 382 void test0() { 383 // CHECK: [[I:%.*]] = alloca [[A:%.*]], align 8 384 // CHECK-NEXT: [[J:%.*]] = alloca [[A]], align 8 385 // CHECK-NEXT: [[T0:%.*]] = alloca [[A]], align 8 386 // CHECK-NEXT: [[K:%.*]] = alloca [[A]], align 8 387 // CHECK-NEXT: [[T1:%.*]] = alloca [[A]], align 8 388 389 // CHECK-NEXT: call void @_ZN7Elision3fooEv() 390 // CHECK-NEXT: call void @_ZN7Elision1AC1Ev([[A]]* [[I]]) 391 A i = (foo(), A()); 392 393 // CHECK-NEXT: call void @_ZN7Elision4fooAEv([[A]]* sret [[T0]]) 394 // CHECK-NEXT: call void @_ZN7Elision1AC1Ev([[A]]* [[J]]) 395 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[T0]]) 396 A j = (fooA(), A()); 397 398 // CHECK-NEXT: call void @_ZN7Elision1AC1Ev([[A]]* [[T1]]) 399 // CHECK-NEXT: call void @_ZN7Elision4fooAEv([[A]]* sret [[K]]) 400 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[T1]]) 401 A k = (A(), fooA()); 402 403 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[K]]) 404 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[J]]) 405 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[I]]) 406 } 407 408 409 // CHECK: define void @_ZN7Elision5test1EbNS_1AE( 410 void test1(bool c, A x) { 411 // CHECK: [[I:%.*]] = alloca [[A]], align 8 412 // CHECK-NEXT: [[J:%.*]] = alloca [[A]], align 8 413 414 // CHECK: call void @_ZN7Elision1AC1Ev([[A]]* [[I]]) 415 // CHECK: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[I]], [[A]]* [[X:%.*]]) 416 A i = (c ? A() : x); 417 418 // CHECK: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[J]], [[A]]* [[X]]) 419 // CHECK: call void @_ZN7Elision1AC1Ev([[A]]* [[J]]) 420 A j = (c ? x : A()); 421 422 // CHECK: call void @_ZN7Elision1AD1Ev([[A]]* [[J]]) 423 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[I]]) 424 } 425 426 // CHECK: define void @_ZN7Elision5test2Ev([[A]]* noalias sret 427 A test2() { 428 // CHECK: call void @_ZN7Elision3fooEv() 429 // CHECK-NEXT: call void @_ZN7Elision1AC1Ev([[A]]* [[RET:%.*]]) 430 // CHECK-NEXT: ret void 431 return (foo(), A()); 432 } 433 434 // CHECK: define void @_ZN7Elision5test3EiNS_1AE([[A]]* noalias sret 435 A test3(int v, A x) { 436 if (v < 5) 437 // CHECK: call void @_ZN7Elision1AC1Ev([[A]]* [[RET:%.*]]) 438 // CHECK: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[RET]], [[A]]* [[X:%.*]]) 439 return (v < 0 ? A() : x); 440 else 441 // CHECK: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[RET]], [[A]]* [[X]]) 442 // CHECK: call void @_ZN7Elision1AC1Ev([[A]]* [[RET]]) 443 return (v > 10 ? x : A()); 444 445 // CHECK: ret void 446 } 447 448 // CHECK: define void @_ZN7Elision5test4Ev() 449 void test4() { 450 // CHECK: [[X:%.*]] = alloca [[A]], align 8 451 // CHECK-NEXT: [[XS:%.*]] = alloca [2 x [[A]]], align 16 452 453 // CHECK-NEXT: call void @_ZN7Elision1AC1Ev([[A]]* [[X]]) 454 A x; 455 456 // CHECK-NEXT: [[XS0:%.*]] = getelementptr inbounds [2 x [[A]]]* [[XS]], i64 0, i64 0 457 // CHECK-NEXT: call void @_ZN7Elision1AC1Ev([[A]]* [[XS0]]) 458 // CHECK-NEXT: [[XS1:%.*]] = getelementptr inbounds [[A]]* [[XS0]], i64 1 459 // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[XS1]], [[A]]* [[X]]) 460 A xs[] = { A(), x }; 461 462 // CHECK-NEXT: [[BEGIN:%.*]] = getelementptr inbounds [2 x [[A]]]* [[XS]], i32 0, i32 0 463 // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[A]]* [[BEGIN]], i64 2 464 // CHECK-NEXT: br label 465 // CHECK: [[AFTER:%.*]] = phi [[A]]* 466 // CHECK-NEXT: [[CUR:%.*]] = getelementptr inbounds [[A]]* [[AFTER]], i64 -1 467 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[CUR]]) 468 // CHECK-NEXT: [[T0:%.*]] = icmp eq [[A]]* [[CUR]], [[BEGIN]] 469 // CHECK-NEXT: br i1 [[T0]], 470 471 // CHECK: call void @_ZN7Elision1AD1Ev([[A]]* [[X]]) 472 } 473 474 // rdar://problem/8433352 475 // CHECK: define void @_ZN7Elision5test5Ev([[A]]* noalias sret 476 struct B { A a; B(); }; 477 A test5() { 478 // CHECK: [[AT0:%.*]] = alloca [[A]], align 8 479 // CHECK-NEXT: [[BT0:%.*]] = alloca [[B:%.*]], align 8 480 // CHECK-NEXT: [[X:%.*]] = alloca [[A]], align 8 481 // CHECK-NEXT: [[BT1:%.*]] = alloca [[B]], align 8 482 // CHECK-NEXT: [[BT2:%.*]] = alloca [[B]], align 8 483 484 // CHECK: call void @_ZN7Elision1BC1Ev([[B]]* [[BT0]]) 485 // CHECK-NEXT: [[AM:%.*]] = getelementptr inbounds [[B]]* [[BT0]], i32 0, i32 0 486 // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[AT0]], [[A]]* [[AM]]) 487 // CHECK-NEXT: call void @_ZN7Elision5takeAENS_1AE([[A]]* [[AT0]]) 488 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[AT0]]) 489 // CHECK-NEXT: call void @_ZN7Elision1BD1Ev([[B]]* [[BT0]]) 490 takeA(B().a); 491 492 // CHECK-NEXT: call void @_ZN7Elision1BC1Ev([[B]]* [[BT1]]) 493 // CHECK-NEXT: [[AM:%.*]] = getelementptr inbounds [[B]]* [[BT1]], i32 0, i32 0 494 // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[X]], [[A]]* [[AM]]) 495 // CHECK-NEXT: call void @_ZN7Elision1BD1Ev([[B]]* [[BT1]]) 496 A x = B().a; 497 498 // CHECK-NEXT: call void @_ZN7Elision1BC1Ev([[B]]* [[BT2]]) 499 // CHECK-NEXT: [[AM:%.*]] = getelementptr inbounds [[B]]* [[BT2]], i32 0, i32 0 500 // CHECK-NEXT: call void @_ZN7Elision1AC1ERKS0_([[A]]* [[RET:%.*]], [[A]]* [[AM]]) 501 // CHECK-NEXT: call void @_ZN7Elision1BD1Ev([[B]]* [[BT2]]) 502 return B().a; 503 504 // CHECK: call void @_ZN7Elision1AD1Ev([[A]]* [[X]]) 505 } 506 507 // Reduced from webkit. 508 // CHECK: define void @_ZN7Elision5test6EPKNS_1CE([[C:%.*]]* 509 struct C { operator A() const; }; 510 void test6(const C *x) { 511 // CHECK: [[T0:%.*]] = alloca [[A]], align 8 512 // CHECK: [[X:%.*]] = load [[C]]** {{%.*}}, align 8 513 // CHECK-NEXT: call void @_ZNK7Elision1CcvNS_1AEEv([[A]]* sret [[T0]], [[C]]* [[X]]) 514 // CHECK-NEXT: call void @_ZNK7Elision1A3fooEv([[A]]* [[T0]]) 515 // CHECK-NEXT: call void @_ZN7Elision1AD1Ev([[A]]* [[T0]]) 516 // CHECK-NEXT: ret void 517 A(*x).foo(); 518 } 519 } 520 521 namespace PR8623 { 522 struct A { A(int); ~A(); }; 523 524 // CHECK: define void @_ZN6PR86233fooEb( 525 void foo(bool b) { 526 // CHECK: [[TMP:%.*]] = alloca [[A:%.*]], align 1 527 // CHECK-NEXT: [[LCONS:%.*]] = alloca i1 528 // CHECK-NEXT: [[RCONS:%.*]] = alloca i1 529 // CHECK: store i1 false, i1* [[LCONS]] 530 // CHECK-NEXT: store i1 false, i1* [[RCONS]] 531 // CHECK-NEXT: br i1 532 // CHECK: call void @_ZN6PR86231AC1Ei([[A]]* [[TMP]], i32 2) 533 // CHECK-NEXT: store i1 true, i1* [[LCONS]] 534 // CHECK-NEXT: br label 535 // CHECK: call void @_ZN6PR86231AC1Ei([[A]]* [[TMP]], i32 3) 536 // CHECK-NEXT: store i1 true, i1* [[RCONS]] 537 // CHECK-NEXT: br label 538 // CHECK: load i1* [[RCONS]] 539 // CHECK-NEXT: br i1 540 // CHECK: call void @_ZN6PR86231AD1Ev([[A]]* [[TMP]]) 541 // CHECK-NEXT: br label 542 // CHECK: load i1* [[LCONS]] 543 // CHECK-NEXT: br i1 544 // CHECK: call void @_ZN6PR86231AD1Ev([[A]]* [[TMP]]) 545 // CHECK-NEXT: br label 546 // CHECK: ret void 547 b ? A(2) : A(3); 548 } 549 } 550 551 namespace PR11365 { 552 struct A { A(); ~A(); }; 553 554 // CHECK: define void @_ZN7PR113653fooEv( 555 void foo() { 556 // CHECK: [[BEGIN:%.*]] = getelementptr inbounds [3 x [[A:%.*]]]* {{.*}}, i32 0, i32 0 557 // CHECK-NEXT: [[END:%.*]] = getelementptr inbounds [[A]]* [[BEGIN]], i64 3 558 // CHECK-NEXT: br label 559 560 // CHECK: [[PHI:%.*]] = phi 561 // CHECK-NEXT: [[ELEM:%.*]] = getelementptr inbounds [[A]]* [[PHI]], i64 -1 562 // CHECK-NEXT: call void @_ZN7PR113651AD1Ev([[A]]* [[ELEM]]) 563 // CHECK-NEXT: icmp eq [[A]]* [[ELEM]], [[BEGIN]] 564 // CHECK-NEXT: br i1 565 (void) (A [3]) {}; 566 } 567 } 568 569 namespace AssignmentOp { 570 struct A { ~A(); }; 571 struct B { A operator=(const B&); }; 572 struct C : B { B b1, b2; }; 573 // CHECK: define void @_ZN12AssignmentOp1fE 574 void f(C &c1, const C &c2) { 575 // CHECK: call {{.*}} @_ZN12AssignmentOp1CaSERKS0_( 576 c1 = c2; 577 } 578 579 // Ensure that each 'A' temporary is destroyed before the next subobject is 580 // copied. 581 // CHECK: define {{.*}} @_ZN12AssignmentOp1CaSERKS0_( 582 // CHECK: call {{.*}} @_ZN12AssignmentOp1BaSERKS 583 // CHECK: call {{.*}} @_ZN12AssignmentOp1AD1Ev( 584 // CHECK: call {{.*}} @_ZN12AssignmentOp1BaSERKS 585 // CHECK: call {{.*}} @_ZN12AssignmentOp1AD1Ev( 586 // CHECK: call {{.*}} @_ZN12AssignmentOp1BaSERKS 587 // CHECK: call {{.*}} @_ZN12AssignmentOp1AD1Ev( 588 } 589 590 namespace BindToSubobject { 591 struct A { 592 A(); 593 ~A(); 594 int a; 595 }; 596 597 void f(), g(); 598 599 // CHECK: call void @_ZN15BindToSubobject1AC1Ev({{.*}} @_ZGRN15BindToSubobject1aE) 600 // CHECK: call i32 @__cxa_atexit({{.*}} bitcast ({{.*}} @_ZN15BindToSubobject1AD1Ev to void (i8*)*), i8* bitcast ({{.*}} @_ZGRN15BindToSubobject1aE to i8*), i8* @__dso_handle) 601 // CHECK: store i32* getelementptr inbounds ({{.*}} @_ZGRN15BindToSubobject1aE, i32 0, i32 0), i32** @_ZN15BindToSubobject1aE, align 8 602 int &&a = A().a; 603 604 // CHECK: call void @_ZN15BindToSubobject1fEv() 605 // CHECK: call void @_ZN15BindToSubobject1AC1Ev({{.*}} @_ZGRN15BindToSubobject1bE) 606 // CHECK: call i32 @__cxa_atexit({{.*}} bitcast ({{.*}} @_ZN15BindToSubobject1AD1Ev to void (i8*)*), i8* bitcast ({{.*}} @_ZGRN15BindToSubobject1bE to i8*), i8* @__dso_handle) 607 // CHECK: store i32* getelementptr inbounds ({{.*}} @_ZGRN15BindToSubobject1bE, i32 0, i32 0), i32** @_ZN15BindToSubobject1bE, align 8 608 int &&b = (f(), A().a); 609 610 int A::*h(); 611 612 // CHECK: call void @_ZN15BindToSubobject1fEv() 613 // CHECK: call void @_ZN15BindToSubobject1gEv() 614 // CHECK: call void @_ZN15BindToSubobject1AC1Ev({{.*}} @_ZGRN15BindToSubobject1cE) 615 // CHECK: call i32 @__cxa_atexit({{.*}} bitcast ({{.*}} @_ZN15BindToSubobject1AD1Ev to void (i8*)*), i8* bitcast ({{.*}} @_ZGRN15BindToSubobject1cE to i8*), i8* @__dso_handle) 616 // CHECK: call {{.*}} @_ZN15BindToSubobject1hE 617 // CHECK: getelementptr 618 // CHECK: store i32* {{.*}}, i32** @_ZN15BindToSubobject1cE, align 8 619 int &&c = (f(), (g(), A().*h())); 620 621 struct B { 622 int padding; 623 A a; 624 }; 625 626 // CHECK: call void @_ZN15BindToSubobject1BC1Ev({{.*}} @_ZGRN15BindToSubobject1dE) 627 // CHECK: call i32 @__cxa_atexit({{.*}} bitcast ({{.*}} @_ZN15BindToSubobject1BD1Ev to void (i8*)*), i8* bitcast ({{.*}} @_ZGRN15BindToSubobject1dE to i8*), i8* @__dso_handle) 628 // CHECK: call {{.*}} @_ZN15BindToSubobject1hE 629 // CHECK: getelementptr {{.*}} getelementptr 630 // CHECK: store i32* {{.*}}, i32** @_ZN15BindToSubobject1dE, align 8 631 int &&d = (B().a).*h(); 632 } 633 634 namespace Bitfield { 635 struct S { int a : 5; ~S(); }; 636 637 // Do not lifetime extend the S() temporary here. 638 // CHECK: alloca 639 // CHECK: call {{.*}}memset 640 // CHECK: store i32 {{.*}}, i32* @_ZGRN8Bitfield1rE 641 // CHECK: call void @_ZN8Bitfield1SD1 642 // CHECK: store i32* @_ZGRN8Bitfield1rE, i32** @_ZN8Bitfield1rE, align 8 643 int &&r = S().a; 644 } 645 646 namespace Vector { 647 typedef __attribute__((vector_size(16))) int vi4a; 648 typedef __attribute__((ext_vector_type(4))) int vi4b; 649 struct S { 650 vi4a v; 651 vi4b w; 652 }; 653 // CHECK: alloca 654 // CHECK: extractelement 655 // CHECK: store i32 {{.*}}, i32* @_ZGRN6Vector1rE 656 // CHECK: store i32* @_ZGRN6Vector1rE, i32** @_ZN6Vector1rE, 657 int &&r = S().v[1]; 658 659 // CHECK: alloca 660 // CHECK: extractelement 661 // CHECK: store i32 {{.*}}, i32* @_ZGRN6Vector1sE 662 // CHECK: store i32* @_ZGRN6Vector1sE, i32** @_ZN6Vector1sE, 663 int &&s = S().w[1]; 664 // FIXME PR16204: The following code leads to an assertion in Sema. 665 //int &&s = S().w.y; 666 } 667 668 namespace ImplicitTemporaryCleanup { 669 struct A { A(int); ~A(); }; 670 void g(); 671 672 // CHECK: define void @_ZN24ImplicitTemporaryCleanup1fEv( 673 void f() { 674 // CHECK: call {{.*}} @_ZN24ImplicitTemporaryCleanup1AC1Ei( 675 A &&a = 0; 676 677 // CHECK: call {{.*}} @_ZN24ImplicitTemporaryCleanup1gEv( 678 g(); 679 680 // CHECK: call {{.*}} @_ZN24ImplicitTemporaryCleanup1AD1Ev( 681 } 682 } 683 684 namespace MultipleExtension { 685 struct A { A(); ~A(); }; 686 struct B { B(); ~B(); }; 687 struct C { C(); ~C(); }; 688 struct D { D(); ~D(); int n; C c; }; 689 struct E { const A &a; B b; const C &c; ~E(); }; 690 691 E &&e1 = { A(), B(), D().c }; 692 693 // CHECK: call void @_ZN17MultipleExtension1AC1Ev({{.*}} @[[TEMPA:_ZGRN17MultipleExtension2e1E.*]]) 694 // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN17MultipleExtension1AD1Ev {{.*}} @[[TEMPA]] 695 // CHECK: store {{.*}} @[[TEMPA]], {{.*}} getelementptr inbounds ({{.*}} @[[TEMPE:_ZGRN17MultipleExtension2e1E.*]], i32 0, i32 0) 696 697 // CHECK: call void @_ZN17MultipleExtension1BC1Ev({{.*}} getelementptr inbounds ({{.*}} @[[TEMPE]], i32 0, i32 1)) 698 699 // CHECK: call void @_ZN17MultipleExtension1DC1Ev({{.*}} @[[TEMPD:_ZGRN17MultipleExtension2e1E.*]]) 700 // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN17MultipleExtension1DD1Ev {{.*}} @[[TEMPD]] 701 // CHECK: store {{.*}} @[[TEMPD]], {{.*}} getelementptr inbounds ({{.*}} @[[TEMPE]], i32 0, i32 2) 702 // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN17MultipleExtension1ED1Ev {{.*}} @[[TEMPE]] 703 // CHECK: store {{.*}} @[[TEMPE]], %"struct.MultipleExtension::E"** @_ZN17MultipleExtension2e1E, align 8 704 705 E e2 = { A(), B(), D().c }; 706 707 // CHECK: call void @_ZN17MultipleExtension1AC1Ev({{.*}} @[[TEMPA:_ZGRN17MultipleExtension2e2E.*]]) 708 // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN17MultipleExtension1AD1Ev {{.*}} @[[TEMPA]] 709 // CHECK: store {{.*}} @[[TEMPA]], {{.*}} getelementptr inbounds ({{.*}} @[[E:_ZN17MultipleExtension2e2E]], i32 0, i32 0) 710 711 // CHECK: call void @_ZN17MultipleExtension1BC1Ev({{.*}} getelementptr inbounds ({{.*}} @[[E]], i32 0, i32 1)) 712 713 // CHECK: call void @_ZN17MultipleExtension1DC1Ev({{.*}} @[[TEMPD:_ZGRN17MultipleExtension2e2E.*]]) 714 // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN17MultipleExtension1DD1Ev {{.*}} @[[TEMPD]] 715 // CHECK: store {{.*}} @[[TEMPD]], {{.*}} getelementptr inbounds ({{.*}} @[[E]], i32 0, i32 2) 716 // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN17MultipleExtension1ED1Ev {{.*}} @[[E]] 717 718 719 void g(); 720 // CHECK: define void @[[NS:_ZN17MultipleExtension]]1fEv( 721 void f() { 722 E &&e1 = { A(), B(), D().c }; 723 // CHECK: %[[TEMPE1_A:.*]] = getelementptr inbounds {{.*}} %[[TEMPE1:.*]], i32 0, i32 0 724 // CHECK: call void @[[NS]]1AC1Ev({{.*}} %[[TEMPA1:.*]]) 725 // CHECK: store {{.*}} %[[TEMPA1]], {{.*}} %[[TEMPE1_A]] 726 // CHECK: %[[TEMPE1_B:.*]] = getelementptr inbounds {{.*}} %[[TEMPE1]], i32 0, i32 1 727 // CHECK: call void @[[NS]]1BC1Ev({{.*}} %[[TEMPE1_B]]) 728 // CHECK: %[[TEMPE1_C:.*]] = getelementptr inbounds {{.*}} %[[TEMPE1]], i32 0, i32 2 729 // CHECK: call void @[[NS]]1DC1Ev({{.*}} %[[TEMPD1:.*]]) 730 // CHECK: %[[TEMPD1_C:.*]] = getelementptr inbounds {{.*}} %[[TEMPD1]], i32 0, i32 1 731 // CHECK: store {{.*}} %[[TEMPD1_C]], {{.*}} %[[TEMPE1_C]] 732 // CHECK: store {{.*}} %[[TEMPE1]], {{.*}} %[[E1:.*]] 733 734 g(); 735 // CHECK: call void @[[NS]]1gEv() 736 737 E e2 = { A(), B(), D().c }; 738 // CHECK: %[[TEMPE2_A:.*]] = getelementptr inbounds {{.*}} %[[E2:.*]], i32 0, i32 0 739 // CHECK: call void @[[NS]]1AC1Ev({{.*}} %[[TEMPA2:.*]]) 740 // CHECK: store {{.*}} %[[TEMPA2]], {{.*}} %[[TEMPE2_A]] 741 // CHECK: %[[TEMPE2_B:.*]] = getelementptr inbounds {{.*}} %[[E2]], i32 0, i32 1 742 // CHECK: call void @[[NS]]1BC1Ev({{.*}} %[[TEMPE2_B]]) 743 // CHECK: %[[TEMPE2_C:.*]] = getelementptr inbounds {{.*}} %[[E2]], i32 0, i32 2 744 // CHECK: call void @[[NS]]1DC1Ev({{.*}} %[[TEMPD2:.*]]) 745 // CHECK: %[[TEMPD2_C:.*]] = getelementptr inbounds {{.*}} %[[TEMPD2]], i32 0, i32 1 746 // CHECK: store {{.*}} %[[TEMPD2_C]], {{.*}}* %[[TEMPE2_C]] 747 748 g(); 749 // CHECK: call void @[[NS]]1gEv() 750 751 // CHECK: call void @[[NS]]1ED1Ev({{.*}} %[[E2]]) 752 // CHECK: call void @[[NS]]1DD1Ev({{.*}} %[[TEMPD2]]) 753 // CHECK: call void @[[NS]]1AD1Ev({{.*}} %[[TEMPA2]]) 754 // CHECK: call void @[[NS]]1ED1Ev({{.*}} %[[TEMPE1]]) 755 // CHECK: call void @[[NS]]1DD1Ev({{.*}} %[[TEMPD1]]) 756 // CHECK: call void @[[NS]]1AD1Ev({{.*}} %[[TEMPA1]]) 757 } 758 } 759 760 namespace PR14130 { 761 struct S { S(int); }; 762 struct U { S &&s; }; 763 U v { { 0 } }; 764 // CHECK: call void @_ZN7PR141301SC1Ei({{.*}} @_ZGRN7PR141301vE, i32 0) 765 // CHECK: store {{.*}} @_ZGRN7PR141301vE, {{.*}} @_ZN7PR141301vE 766 } 767 768 namespace Ctor { 769 struct A { A(); ~A(); }; 770 void f(); 771 struct B { 772 A &&a; 773 B() : a{} { f(); } 774 } b; 775 // CHECK: define {{.*}}void @_ZN4Ctor1BC1Ev( 776 // CHECK: call void @_ZN4Ctor1AC1Ev( 777 // CHECK: call void @_ZN4Ctor1fEv( 778 // CHECK: call void @_ZN4Ctor1AD1Ev( 779 } 780