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