OLD | NEW |
1 //===--- CGClass.cpp - Emit LLVM Code for C++ classes ---------------------===// | 1 //===--- CGClass.cpp - Emit LLVM Code for C++ classes ---------------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This contains code dealing with C++ code generation of classes | 10 // This contains code dealing with C++ code generation of classes |
(...skipping 1496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1507 ·· | 1507 ·· |
1508 if (!NonVirtualOffset.isZero() || VirtualOffset) | 1508 if (!NonVirtualOffset.isZero() || VirtualOffset) |
1509 VTableField = ApplyNonVirtualAndVirtualOffset(*this, VTableField,· | 1509 VTableField = ApplyNonVirtualAndVirtualOffset(*this, VTableField,· |
1510 NonVirtualOffset, | 1510 NonVirtualOffset, |
1511 VirtualOffset); | 1511 VirtualOffset); |
1512 | 1512 |
1513 // Finally, store the address point. | 1513 // Finally, store the address point. |
1514 llvm::Type *AddressPointPtrTy = | 1514 llvm::Type *AddressPointPtrTy = |
1515 VTableAddressPoint->getType()->getPointerTo(); | 1515 VTableAddressPoint->getType()->getPointerTo(); |
1516 VTableField = Builder.CreateBitCast(VTableField, AddressPointPtrTy); | 1516 VTableField = Builder.CreateBitCast(VTableField, AddressPointPtrTy); |
1517 Builder.CreateStore(VTableAddressPoint, VTableField); | 1517 llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, VTableField); |
| 1518 CGM.DecorateInstruction(Store, CGM.getTBAAInfoForVTablePtr()); |
1518 } | 1519 } |
1519 | 1520 |
1520 void | 1521 void |
1521 CodeGenFunction::InitializeVTablePointers(BaseSubobject Base,· | 1522 CodeGenFunction::InitializeVTablePointers(BaseSubobject Base,· |
1522 const CXXRecordDecl *NearestVBase, | 1523 const CXXRecordDecl *NearestVBase, |
1523 CharUnits OffsetFromNearestVBase, | 1524 CharUnits OffsetFromNearestVBase, |
1524 bool BaseIsNonVirtualPrimaryBase, | 1525 bool BaseIsNonVirtualPrimaryBase, |
1525 llvm::Constant *VTable, | 1526 llvm::Constant *VTable, |
1526 const CXXRecordDecl *VTableClass, | 1527 const CXXRecordDecl *VTableClass, |
1527 VisitedVirtualBasesSetTy& VBases) { | 1528 VisitedVirtualBasesSetTy& VBases) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1590 InitializeVTablePointers(BaseSubobject(RD, CharUnits::Zero()),· | 1591 InitializeVTablePointers(BaseSubobject(RD, CharUnits::Zero()),· |
1591 /*NearestVBase=*/0,· | 1592 /*NearestVBase=*/0,· |
1592 /*OffsetFromNearestVBase=*/CharUnits::Zero(), | 1593 /*OffsetFromNearestVBase=*/CharUnits::Zero(), |
1593 /*BaseIsNonVirtualPrimaryBase=*/false,· | 1594 /*BaseIsNonVirtualPrimaryBase=*/false,· |
1594 VTable, RD, VBases); | 1595 VTable, RD, VBases); |
1595 } | 1596 } |
1596 | 1597 |
1597 llvm::Value *CodeGenFunction::GetVTablePtr(llvm::Value *This, | 1598 llvm::Value *CodeGenFunction::GetVTablePtr(llvm::Value *This, |
1598 llvm::Type *Ty) { | 1599 llvm::Type *Ty) { |
1599 llvm::Value *VTablePtrSrc = Builder.CreateBitCast(This, Ty->getPointerTo()); | 1600 llvm::Value *VTablePtrSrc = Builder.CreateBitCast(This, Ty->getPointerTo()); |
1600 return Builder.CreateLoad(VTablePtrSrc, "vtable"); | 1601 llvm::Instruction *VTable = Builder.CreateLoad(VTablePtrSrc, "vtable"); |
| 1602 CGM.DecorateInstruction(VTable, CGM.getTBAAInfoForVTablePtr()); |
| 1603 return VTable; |
1601 } | 1604 } |
1602 | 1605 |
1603 static const CXXRecordDecl *getMostDerivedClassDecl(const Expr *Base) { | 1606 static const CXXRecordDecl *getMostDerivedClassDecl(const Expr *Base) { |
1604 const Expr *E = Base; | 1607 const Expr *E = Base; |
1605 ·· | 1608 ·· |
1606 while (true) { | 1609 while (true) { |
1607 E = E->IgnoreParens(); | 1610 E = E->IgnoreParens(); |
1608 if (const CastExpr *CE = dyn_cast<CastExpr>(E)) { | 1611 if (const CastExpr *CE = dyn_cast<CastExpr>(E)) { |
1609 if (CE->getCastKind() == CK_DerivedToBase ||· | 1612 if (CE->getCastKind() == CK_DerivedToBase ||· |
1610 CE->getCastKind() == CK_UncheckedDerivedToBase || | 1613 CE->getCastKind() == CK_UncheckedDerivedToBase || |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1821 void CodeGenFunction::EmitLambdaStaticInvokeFunction(const CXXMethodDecl *MD) { | 1824 void CodeGenFunction::EmitLambdaStaticInvokeFunction(const CXXMethodDecl *MD) { |
1822 if (MD->isVariadic()) { | 1825 if (MD->isVariadic()) { |
1823 // FIXME: Making this work correctly is nasty because it requires either | 1826 // FIXME: Making this work correctly is nasty because it requires either |
1824 // cloning the body of the call operator or making the call operator forward
. | 1827 // cloning the body of the call operator or making the call operator forward
. |
1825 CGM.ErrorUnsupported(MD, "lambda conversion to variadic function"); | 1828 CGM.ErrorUnsupported(MD, "lambda conversion to variadic function"); |
1826 return; | 1829 return; |
1827 } | 1830 } |
1828 | 1831 |
1829 EmitLambdaDelegatingInvokeBody(MD); | 1832 EmitLambdaDelegatingInvokeBody(MD); |
1830 } | 1833 } |
OLD | NEW |