27 #include "llvm/IR/Intrinsics.h" 28 #include "llvm/IR/Metadata.h" 29 #include "llvm/Transforms/Utils/SanitizerStats.h" 31 using namespace clang;
32 using namespace CodeGen;
49 return layout.getNonVirtualAlignment();
63 CharUnits expectedVBaseAlign = baseLayout.getNonVirtualAlignment();
76 return std::min(actualBaseAlign, expectedTargetAlign);
79 CharUnits expectedBaseAlign = baseLayout.getNonVirtualAlignment();
99 if (actualBaseAlign >= expectedBaseAlign) {
100 return expectedTargetAlign;
106 return std::min(actualBaseAlign, expectedTargetAlign);
110 assert(CurFuncDecl &&
"loading 'this' without a func declaration?");
111 assert(isa<CXXMethodDecl>(CurFuncDecl));
114 if (CXXThisAlignment.isZero()) {
118 auto RD = cast<CXXMethodDecl>(CurFuncDecl)->getParent();
119 CXXThisAlignment = CGM.getClassPointerAlignment(RD);
122 return Address(LoadCXXThis(), CXXThisAlignment);
136 CGM.getCXXABI().EmitMemberDataPointerAddress(*
this, E, base,
137 memberPtr, memberPtrType);
140 CharUnits memberAlign = getNaturalTypeAlignment(memberType, BaseInfo,
146 return Address(ptr, memberAlign);
159 assert(!Base->
isVirtual() &&
"Should not see virtual bases here!");
168 Offset += Layout.getBaseClassOffset(BaseDecl);
180 assert(PathBegin != PathEnd &&
"Base path should not be empty!");
190 return llvm::ConstantInt::get(PtrDiffTy, Offset.
getQuantity());
202 bool BaseIsVirtual) {
217 if (!Offset.isZero()) {
218 V = Builder.CreateElementBitCast(V,
Int8Ty);
219 V = Builder.CreateConstInBoundsByteGEP(V, Offset);
221 V = Builder.CreateElementBitCast(V, ConvertType(Base));
233 assert(!nonVirtualOffset.
isZero() || virtualOffset !=
nullptr);
237 if (!nonVirtualOffset.
isZero()) {
238 baseOffset = llvm::ConstantInt::get(CGF.
PtrDiffTy,
241 baseOffset = CGF.
Builder.CreateAdd(virtualOffset, baseOffset);
244 baseOffset = virtualOffset;
250 ptr = CGF.
Builder.CreateInBoundsGEP(ptr, baseOffset,
"add.ptr");
256 assert(nearestVBase &&
"virtual offset without vbase?");
258 derivedClass, nearestVBase);
264 return Address(ptr, alignment);
272 assert(PathBegin != PathEnd &&
"Base path should not be empty!");
281 if ((*Start)->isVirtual()) {
283 cast<CXXRecordDecl>((*Start)->getType()->getAs<
RecordType>()->getDecl());
290 CharUnits NonVirtualOffset = CGM.computeNonVirtualBaseClassOffset(
291 VBase ? VBase : Derived, Start, PathEnd);
296 if (VBase && Derived->
hasAttr<FinalAttr>()) {
299 NonVirtualOffset += vBaseOffset;
305 ConvertType((PathEnd[-1])->getType())
306 ->getPointerTo(Value.
getType()->getPointerAddressSpace());
309 CharUnits DerivedAlign = CGM.getClassPointerAlignment(Derived);
313 if (NonVirtualOffset.
isZero() && !VBase) {
314 if (sanitizePerformTypeCheck()) {
316 SkippedChecks.
set(SanitizerKind::Null, !NullCheckValue);
317 EmitTypeCheck(TCK_Upcast, Loc, Value.
getPointer(),
318 DerivedTy, DerivedAlign, SkippedChecks);
320 return Builder.CreateBitCast(Value, BasePtrTy);
323 llvm::BasicBlock *origBB =
nullptr;
324 llvm::BasicBlock *endBB =
nullptr;
328 if (NullCheckValue) {
329 origBB = Builder.GetInsertBlock();
330 llvm::BasicBlock *notNullBB = createBasicBlock(
"cast.notnull");
331 endBB = createBasicBlock(
"cast.end");
334 Builder.CreateCondBr(isNull, endBB, notNullBB);
335 EmitBlock(notNullBB);
338 if (sanitizePerformTypeCheck()) {
340 SkippedChecks.
set(SanitizerKind::Null,
true);
341 EmitTypeCheck(VBase ? TCK_UpcastToVirtualBase : TCK_Upcast, Loc,
342 Value.
getPointer(), DerivedTy, DerivedAlign, SkippedChecks);
349 CGM.getCXXABI().GetVirtualBaseClassOffset(*
this, Value, Derived, VBase);
354 VirtualOffset, Derived, VBase);
357 Value = Builder.CreateBitCast(Value, BasePtrTy);
360 if (NullCheckValue) {
361 llvm::BasicBlock *notNullBB = Builder.GetInsertBlock();
362 Builder.CreateBr(endBB);
365 llvm::PHINode *PHI = Builder.CreatePHI(BasePtrTy, 2,
"cast.result");
366 PHI->addIncoming(Value.
getPointer(), notNullBB);
367 PHI->addIncoming(llvm::Constant::getNullValue(BasePtrTy), origBB);
379 bool NullCheckValue) {
380 assert(PathBegin != PathEnd &&
"Base path should not be empty!");
384 llvm::Type *DerivedPtrTy = ConvertType(DerivedTy)->getPointerTo();
387 CGM.GetNonVirtualBaseClassOffset(Derived, PathBegin, PathEnd);
389 if (!NonVirtualOffset) {
391 return Builder.CreateBitCast(BaseAddr, DerivedPtrTy);
394 llvm::BasicBlock *CastNull =
nullptr;
395 llvm::BasicBlock *CastNotNull =
nullptr;
396 llvm::BasicBlock *CastEnd =
nullptr;
398 if (NullCheckValue) {
399 CastNull = createBasicBlock(
"cast.null");
400 CastNotNull = createBasicBlock(
"cast.notnull");
401 CastEnd = createBasicBlock(
"cast.end");
404 Builder.CreateCondBr(IsNull, CastNull, CastNotNull);
405 EmitBlock(CastNotNull);
410 Value = Builder.CreateInBoundsGEP(Value, Builder.CreateNeg(NonVirtualOffset),
414 Value = Builder.CreateBitCast(Value, DerivedPtrTy);
417 if (NullCheckValue) {
418 Builder.CreateBr(CastEnd);
420 Builder.CreateBr(CastEnd);
423 llvm::PHINode *PHI = Builder.CreatePHI(Value->getType(), 2);
424 PHI->addIncoming(Value, CastNotNull);
425 PHI->addIncoming(llvm::Constant::getNullValue(Value->getType()), CastNull);
429 return Address(Value, CGM.getClassPointerAlignment(Derived));
435 if (!CGM.getCXXABI().NeedsVTTParameter(GD)) {
440 const CXXRecordDecl *RD = cast<CXXMethodDecl>(CurCodeDecl)->getParent();
445 uint64_t SubVTTIndex;
450 }
else if (RD == Base) {
453 assert(!CGM.getCXXABI().NeedsVTTParameter(CurGD) &&
454 "doing no-op VTT offset in base dtor/ctor?");
455 assert(!ForVirtualBase &&
"Can't have same class as virtual base!");
464 CGM.getVTables().getSubVTTIndex(RD,
BaseSubobject(Base, BaseOffset));
465 assert(SubVTTIndex != 0 &&
"Sub-VTT index must be greater than zero!");
468 if (CGM.getCXXABI().NeedsVTTParameter(CurGD)) {
471 VTT = Builder.CreateConstInBoundsGEP1_64(VTT, SubVTTIndex);
474 VTT = CGM.getVTables().GetAddrOfVTT(RD);
475 VTT = Builder.CreateConstInBoundsGEP2_64(VTT, 0, SubVTTIndex);
487 : BaseClass(Base), BaseIsVirtual(BaseIsVirtual) {}
499 DerivedClass, BaseClass,
502 false, Addr, ThisTy);
513 DynamicThisUseChecker(
const ASTContext &C) : super(C), UsesThis(
false) {}
520 void VisitCXXThisExpr(
const CXXThisExpr *E) { UsesThis =
true; }
525 DynamicThisUseChecker Checker(C);
527 return Checker.UsesThis;
534 "Must have base initializer!");
574 if (!(CD && CD->isCopyOrMoveConstructor()) &&
596 for (
const auto *I : IndirectField->
chain())
610 "Must have member initializer!");
611 assert(MemberInit->
getInit() &&
"Must have initializer!");
615 QualType FieldType = Field->getType();
643 unsigned SrcArgIndex =
668 switch (getEvaluationKind(FieldType)) {
671 EmitExprAsInit(Init, Field, LHS,
false);
674 EmitStoreThroughLValue(RHS, LHS);
678 EmitComplexExprIntoLValue(Init, LHS,
true);
687 getOverlapForFieldInit(Field),
691 EmitAggExpr(Init, Slot);
699 if (needsEHCleanup(dtorKind))
700 pushEHDestroy(dtorKind, LHS.
getAddress(), FieldType);
758 Prologue ? cast<CXXConstructorDecl>(CurGD.getDecl())->getParent()
759 : cast<CXXDestructorDecl>(CurGD.getDecl())->getParent();
762 struct SizeAndOffset {
767 unsigned PtrSize = CGM.getDataLayout().getPointerSizeInBits();
776 size_t NumFields = 0;
777 for (
const auto *Field : ClassDecl->
fields()) {
779 std::pair<CharUnits, CharUnits> FieldInfo =
782 assert(NumFields < SSV.size());
786 assert(NumFields == SSV.size());
787 if (SSV.size() <= 1)
return;
792 llvm::FunctionType *FTy =
793 llvm::FunctionType::get(CGM.VoidTy, Args,
false);
794 llvm::FunctionCallee F = CGM.CreateRuntimeFunction(
795 FTy, Prologue ?
"__asan_poison_intra_object_redzone" 796 :
"__asan_unpoison_intra_object_redzone");
799 ThisPtr = Builder.CreatePtrToInt(ThisPtr, IntPtrTy);
803 for (
size_t i = 0;
i < SSV.size();
i++) {
804 uint64_t AsanAlignment = 8;
805 uint64_t NextField =
i == SSV.size() - 1 ? TypeSize : SSV[
i + 1].Offset;
806 uint64_t PoisonSize = NextField - SSV[
i].Offset - SSV[
i].Size;
807 uint64_t EndOffset = SSV[
i].Offset + SSV[
i].Size;
808 if (PoisonSize < AsanAlignment || !SSV[
i].Size ||
809 (NextField % AsanAlignment) != 0)
812 F, {Builder.CreateAdd(ThisPtr, Builder.getIntN(PtrSize, EndOffset)),
813 Builder.getIntN(PtrSize, PoisonSize)});
819 EmitAsanPrologueOrEpilogue(
true);
823 assert((CGM.getTarget().getCXXABI().hasConstructorVariants() ||
825 "can only generate complete ctor for this ABI");
829 if (CtorType ==
Ctor_Complete && IsConstructorDelegationValid(Ctor) &&
830 CGM.getTarget().getCXXABI().hasConstructorVariants()) {
837 assert(Definition == Ctor &&
"emitting wrong constructor body");
841 bool IsTryBody = (Body && isa<CXXTryStmt>(Body));
843 EnterCXXTryStmt(*cast<CXXTryStmt>(Body),
true);
845 incrementProfileCounter(Body);
854 EmitCtorPrologue(Ctor, CtorType, Args);
858 EmitStmt(cast<CXXTryStmt>(Body)->getTryBlock());
869 ExitCXXTryStmt(*cast<CXXTryStmt>(Body),
true);
877 class CopyingValueRepresentation {
880 : CGF(CGF), OldSanOpts(CGF.
SanOpts) {
884 ~CopyingValueRepresentation() {
894 class FieldMemcpyizer {
898 : CGF(CGF), ClassDecl(ClassDecl), SrcRec(SrcRec),
900 FirstField(
nullptr), LastField(
nullptr), FirstFieldOffset(0),
901 LastFieldOffset(0), LastAddedFieldIndex(0) {}
903 bool isMemcpyableField(
FieldDecl *F)
const {
920 CharUnits getMemcpySize(uint64_t FirstByteOffset)
const {
922 unsigned LastFieldSize =
923 LastField->isBitField()
924 ? LastField->getBitWidthValue(Ctx)
927 uint64_t MemcpySizeBits = LastFieldOffset + LastFieldSize -
940 uint64_t FirstByteOffset;
941 if (FirstField->isBitField()) {
949 FirstByteOffset = FirstFieldOffset;
952 CharUnits MemcpySize = getMemcpySize(FirstByteOffset);
968 FirstField =
nullptr;
977 llvm::PointerType *DPT = DestPtr.
getType();
979 llvm::Type::getInt8PtrTy(CGF.
getLLVMContext(), DPT->getAddressSpace());
982 llvm::PointerType *SPT = SrcPtr.
getType();
984 llvm::Type::getInt8PtrTy(CGF.
getLLVMContext(), SPT->getAddressSpace());
993 FirstFieldOffset = RecLayout.getFieldOffset(F->
getFieldIndex());
994 LastFieldOffset = FirstFieldOffset;
1004 "Cannot aggregate fields out of order.");
1010 uint64_t FOffset = RecLayout.getFieldOffset(F->
getFieldIndex());
1011 if (FOffset < FirstFieldOffset) {
1013 FirstFieldOffset = FOffset;
1014 }
else if (FOffset >= LastFieldOffset) {
1016 LastFieldOffset = FOffset;
1024 uint64_t FirstFieldOffset, LastFieldOffset;
1025 unsigned LastAddedFieldIndex;
1028 class ConstructorMemcpyizer :
public FieldMemcpyizer {
1043 if (!MemcpyableCtor)
1046 assert(Field &&
"No field for member init.");
1057 if (!isMemcpyableField(Field))
1067 : FieldMemcpyizer(CGF, CD->
getParent(), getTrivialCopySource(CGF, CD, Args)),
1068 ConstructorDecl(CD),
1075 if (isMemberInitMemcpyable(MemberInit)) {
1076 AggregatedInits.push_back(MemberInit);
1077 addMemcpyableField(MemberInit->
getMember());
1079 emitAggregatedInits();
1081 ConstructorDecl, Args);
1085 void emitAggregatedInits() {
1086 if (AggregatedInits.size() <= 1) {
1089 if (!AggregatedInits.empty()) {
1090 CopyingValueRepresentation CVR(CGF);
1092 AggregatedInits[0], ConstructorDecl, Args);
1093 AggregatedInits.clear();
1099 pushEHDestructors();
1101 AggregatedInits.clear();
1104 void pushEHDestructors() {
1109 for (
unsigned i = 0;
i < AggregatedInits.size(); ++
i) {
1122 emitAggregatedInits();
1127 bool MemcpyableCtor;
1132 class AssignmentMemcpyizer :
public FieldMemcpyizer {
1137 if (!AssignmentsMemcpyable)
1141 if (BO->getOpcode() != BO_Assign)
1147 if (!Field || !isMemcpyableField(Field))
1149 Stmt *RHS = BO->getRHS();
1151 RHS = EC->getSubExpr();
1154 if (
MemberExpr *ME2 = dyn_cast<MemberExpr>(RHS)) {
1155 if (ME2->getMemberDecl() == Field)
1167 if (!Field || !isMemcpyableField(Field))
1170 if (!Arg0 || Field != dyn_cast<FieldDecl>(Arg0->
getMemberDecl()))
1173 }
else if (
CallExpr *CE = dyn_cast<CallExpr>(S)) {
1175 if (!FD || FD->
getBuiltinID() != Builtin::BI__builtin_memcpy)
1177 Expr *DstPtr = CE->getArg(0);
1179 DstPtr = DC->getSubExpr();
1181 if (!DUO || DUO->
getOpcode() != UO_AddrOf)
1187 if (!Field || !isMemcpyableField(Field))
1189 Expr *SrcPtr = CE->getArg(1);
1191 SrcPtr = SC->getSubExpr();
1193 if (!SUO || SUO->
getOpcode() != UO_AddrOf)
1196 if (!ME2 || Field != dyn_cast<FieldDecl>(ME2->
getMemberDecl()))
1204 bool AssignmentsMemcpyable;
1210 : FieldMemcpyizer(CGF, AD->
getParent(), Args[Args.size() - 1]),
1212 assert(Args.size() == 2);
1215 void emitAssignment(
Stmt *S) {
1218 addMemcpyableField(F);
1219 AggregatedStmts.push_back(S);
1221 emitAggregatedStmts();
1226 void emitAggregatedStmts() {
1227 if (AggregatedStmts.size() <= 1) {
1228 if (!AggregatedStmts.empty()) {
1229 CopyingValueRepresentation CVR(CGF);
1236 AggregatedStmts.clear();
1240 emitAggregatedStmts();
1247 const auto *BaseClassDecl =
1249 return BaseClassDecl->isDynamicClass();
1258 return EmitDelegatingCXXConstructorCall(CD, Args);
1272 bool ConstructVBases = CtorType !=
Ctor_Base &&
1279 llvm::BasicBlock *BaseCtorContinueBB =
nullptr;
1280 if (ConstructVBases &&
1281 !CGM.getTarget().getCXXABI().hasConstructorVariants()) {
1282 BaseCtorContinueBB =
1283 CGM.getCXXABI().EmitCtorCompleteObjectHandler(*
this, ClassDecl);
1284 assert(BaseCtorContinueBB);
1288 for (; B != E && (*B)->isBaseInitializer() && (*B)->isBaseVirtual(); B++) {
1289 if (!ConstructVBases)
1291 if (CGM.getCodeGenOpts().StrictVTablePointers &&
1292 CGM.getCodeGenOpts().OptimizationLevel > 0 &&
1294 CXXThisValue = Builder.CreateLaunderInvariantGroup(LoadCXXThis());
1298 if (BaseCtorContinueBB) {
1300 Builder.CreateBr(BaseCtorContinueBB);
1301 EmitBlock(BaseCtorContinueBB);
1305 for (; B != E && (*B)->isBaseInitializer(); B++) {
1306 assert(!(*B)->isBaseVirtual());
1308 if (CGM.getCodeGenOpts().StrictVTablePointers &&
1309 CGM.getCodeGenOpts().OptimizationLevel > 0 &&
1311 CXXThisValue = Builder.CreateLaunderInvariantGroup(LoadCXXThis());
1315 CXXThisValue = OldThis;
1317 InitializeVTablePointers(ClassDecl);
1321 ConstructorMemcpyizer CM(*
this, CD, Args);
1322 for (; B != E; B++) {
1326 "Delegating initializer on non-delegating constructor");
1327 CM.addMemberInitializer(Member);
1348 for (
const auto *Field : BaseClassDecl->
fields())
1353 for (
const auto &I : BaseClassDecl->
bases()) {
1358 cast<CXXRecordDecl>(I.getType()->castAs<
RecordType>()->getDecl());
1360 MostDerivedClassDecl))
1364 if (BaseClassDecl == MostDerivedClassDecl) {
1366 for (
const auto &I : BaseClassDecl->
vbases()) {
1368 cast<CXXRecordDecl>(I.getType()->castAs<
RecordType>()->getDecl());
1370 MostDerivedClassDecl))
1409 for (
const auto *Field : ClassDecl->
fields())
1427 llvm::CallInst *TrapCall = EmitTrapCall(llvm::Intrinsic::trap);
1428 TrapCall->setDoesNotReturn();
1429 TrapCall->setDoesNotThrow();
1430 Builder.CreateUnreachable();
1431 Builder.ClearInsertionPoint();
1437 incrementProfileCounter(Body);
1446 if (HaveInsertPoint()) {
1449 false, LoadCXXThisAddress(), ThisTy);
1456 bool isTryBody = (Body && isa<CXXTryStmt>(Body));
1458 EnterCXXTryStmt(*cast<CXXTryStmt>(Body),
true);
1459 EmitAsanPrologueOrEpilogue(
false);
1470 case Dtor_Comdat: llvm_unreachable(
"not expecting a COMDAT");
1471 case Dtor_Deleting: llvm_unreachable(
"already handled deleting case");
1475 "can't emit a dtor without a body for non-Microsoft ABIs");
1482 EmitCXXDestructorCall(Dtor,
Dtor_Base,
false,
1483 false, LoadCXXThisAddress(), ThisTy);
1500 if (CGM.getCodeGenOpts().StrictVTablePointers &&
1501 CGM.getCodeGenOpts().OptimizationLevel > 0)
1502 CXXThisValue = Builder.CreateLaunderInvariantGroup(LoadCXXThis());
1503 InitializeVTablePointers(Dtor->
getParent());
1507 EmitStmt(cast<CXXTryStmt>(Body)->getTryBlock());
1511 assert(Dtor->
isImplicit() &&
"bodyless dtor not implicit");
1517 CurFn->addFnAttr(llvm::Attribute::AlwaysInline);
1527 ExitCXXTryStmt(*cast<CXXTryStmt>(Body),
true);
1531 const CXXMethodDecl *AssignOp = cast<CXXMethodDecl>(CurGD.getDecl());
1533 assert(isa<CompoundStmt>(RootS) &&
1534 "Body of an implicit assignment operator should be compound stmt.");
1535 const CompoundStmt *RootCS = cast<CompoundStmt>(RootS);
1539 incrementProfileCounter(RootCS);
1540 AssignmentMemcpyizer AM(*
this, AssignOp, Args);
1541 for (
auto *I : RootCS->
body())
1542 AM.emitAssignment(I);
1562 LoadThisForDtorDelete(CGF, Dtor),
1569 bool ReturnAfterDelete) {
1573 = CGF.
Builder.CreateIsNull(ShouldDeleteCondition);
1574 CGF.
Builder.CreateCondBr(ShouldCallDelete, continueBB, callDeleteBB);
1580 LoadThisForDtorDelete(CGF, Dtor),
1583 ReturnAfterDelete &&
1584 "unexpected value for ReturnAfterDelete");
1585 if (ReturnAfterDelete)
1588 CGF.
Builder.CreateBr(continueBB);
1597 CallDtorDeleteConditional(
llvm::Value *ShouldDeleteCondition)
1598 : ShouldDeleteCondition(ShouldDeleteCondition) {
1599 assert(ShouldDeleteCondition !=
nullptr);
1603 EmitConditionalDtorDeleteCall(CGF, ShouldDeleteCondition,
1611 bool useEHCleanupForArray;
1615 bool useEHCleanupForArray)
1616 : field(field), destroyer(destroyer),
1617 useEHCleanupForArray(useEHCleanupForArray) {}
1628 flags.isForNormalCleanup() && useEHCleanupForArray);
1638 llvm::ConstantInt::get(CGF.
SizeTy, PoisonSize)};
1642 llvm::FunctionType *FnType =
1643 llvm::FunctionType::get(CGF.
VoidTy, ArgTypes,
false);
1644 llvm::FunctionCallee Fn =
1667 CGF.
CurFn->addFnAttr(
"disable-tail-calls",
"true");
1672 unsigned fieldIndex = 0;
1673 int startIndex = -1;
1680 startIndex = fieldIndex;
1687 }
else if (startIndex >= 0) {
1689 PoisonMembers(CGF, startIndex, fieldIndex);
1703 unsigned layoutEndOffset) {
1708 llvm::ConstantInt *OffsetSizePtr = llvm::ConstantInt::get(
1730 if (PoisonSize == 0)
1733 EmitSanitizerDtorCallback(CGF, OffsetPtr, PoisonSize);
1755 EmitSanitizerDtorCallback(CGF, VTablePtr, PoisonSize);
1769 "Should not emit dtor epilogue for non-exported trivial dtor!");
1775 "operator delete missing - EnterDtorCleanups");
1776 if (CXXStructorImplicitParamValue) {
1780 EmitConditionalDtorDeleteCall(*
this, CXXStructorImplicitParamValue,
1783 EHStack.pushCleanup<CallDtorDeleteConditional>(
1789 LoadThisForDtorDelete(*
this, DD),
1791 EmitBranchThroughCleanup(ReturnBlock);
1809 if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor &&
1810 SanOpts.has(SanitizerKind::Memory) && ClassDecl->
getNumVBases() &&
1816 for (
const auto &
Base : ClassDecl->
vbases()) {
1818 = cast<CXXRecordDecl>(
Base.getType()->getAs<
RecordType>()->getDecl());
1835 if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor &&
1836 SanOpts.has(SanitizerKind::Memory) && !ClassDecl->
getNumVBases() &&
1841 for (
const auto &
Base : ClassDecl->
bases()) {
1843 if (
Base.isVirtual())
1859 if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor &&
1860 SanOpts.has(SanitizerKind::Memory))
1864 for (
const auto *Field : ClassDecl->
fields()) {
1867 if (!dtorKind)
continue;
1873 CleanupKind cleanupKind = getCleanupKind(dtorKind);
1874 EHStack.pushCleanup<DestroyField>(cleanupKind, Field,
1875 getDestroyer(dtorKind),
1891 bool zeroInitialize) {
1894 emitArrayLength(arrayType, elementType, arrayBegin);
1896 EmitCXXAggrConstructorCall(ctor, numElements, arrayBegin, E,
1897 NewPointerIsChecked, zeroInitialize);
1913 bool NewPointerIsChecked,
1914 bool zeroInitialize) {
1920 llvm::BranchInst *zeroCheckBranch =
nullptr;
1923 llvm::ConstantInt *constantCount
1924 = dyn_cast<llvm::ConstantInt>(numElements);
1925 if (constantCount) {
1927 if (constantCount->isZero())
return;
1931 llvm::BasicBlock *loopBB = createBasicBlock(
"new.ctorloop");
1932 llvm::Value *iszero = Builder.CreateIsNull(numElements,
"isempty");
1933 zeroCheckBranch = Builder.CreateCondBr(iszero, loopBB, loopBB);
1939 llvm::Value *arrayEnd = Builder.CreateInBoundsGEP(arrayBegin, numElements,
1943 llvm::BasicBlock *entryBB = Builder.GetInsertBlock();
1944 llvm::BasicBlock *loopBB = createBasicBlock(
"arrayctor.loop");
1946 llvm::PHINode *cur = Builder.CreatePHI(arrayBegin->getType(), 2,
1948 cur->addIncoming(arrayBegin, entryBB);
1966 EmitNullInitialization(curAddr, type);
1983 Destroyer *destroyer = destroyCXXObject;
1984 pushRegularPartialArrayCleanup(arrayBegin, cur, type, eltAlignment,
1999 Builder.CreateInBoundsGEP(cur, llvm::ConstantInt::get(
SizeTy, 1),
2001 cur->addIncoming(next, Builder.GetInsertBlock());
2004 llvm::Value *done = Builder.CreateICmpEQ(next, arrayEnd,
"arrayctor.done");
2005 llvm::BasicBlock *contBB = createBasicBlock(
"arrayctor.cont");
2006 Builder.CreateCondBr(done, contBB, loopBB);
2009 if (zeroCheckBranch) zeroCheckBranch->setSuccessor(0, contBB);
2020 assert(!dtor->isTrivial());
2027 bool ForVirtualBase,
2038 if (SlotAS != ThisAS) {
2041 ThisPtr->getType()->getPointerElementType()->getPointerTo(TargetThisAS);
2042 ThisPtr = getTargetHooks().performAddrSpaceCast(*
this, This.
getPointer(),
2043 ThisAS, SlotAS, NewType);
2053 assert(E->
getNumArgs() == 1 &&
"unexpected argcount for trivial ctor");
2056 LValue Src = EmitLValue(Arg);
2058 LValue Dest = MakeAddrLValue(This, DestTy);
2059 EmitAggregateCopyCtor(Dest, Src, ThisAVS.
mayOverlap());
2066 ? EvaluationOrder::ForceLeftToRight
2071 EmitCXXConstructorCall(D, Type, ForVirtualBase, Delegating, This, Args,
2086 if (
P->getType().isDestructedType())
2102 bool ForVirtualBase,
2108 bool NewPointerIsChecked) {
2111 if (!NewPointerIsChecked)
2116 assert(Args.size() == 1 &&
"trivial default ctor with args");
2124 assert(Args.size() == 2 &&
"unexpected argcount for trivial ctor");
2127 Address Src(Args[1].getRValue(*this).getScalarVal(),
2128 getNaturalTypeAlignment(SrcTy));
2129 LValue SrcLVal = MakeAddrLValue(Src, SrcTy);
2131 LValue DestLVal = MakeAddrLValue(This, DestTy);
2132 EmitAggregateCopyCtor(DestLVal, SrcLVal, Overlap);
2136 bool PassPrototypeArgs =
true;
2141 EmitInlinedInheritingCXXConstructorCall(D, Type, ForVirtualBase,
2149 CGM.getCXXABI().addImplicitConstructorArgs(*
this, D, Type, ForVirtualBase,
2153 llvm::Constant *CalleePtr = CGM.getAddrOfCXXStructor(
GlobalDecl(D, Type));
2154 const CGFunctionInfo &Info = CGM.getTypes().arrangeCXXConstructorCall(
2155 Args, D, Type, ExtraArgs.
Prefix, ExtraArgs.
Suffix, PassPrototypeArgs);
2170 if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
2172 CGM.getCXXABI().canSpeculativelyEmitVTable(ClassDecl) &&
2173 CGM.getCodeGenOpts().StrictVTablePointers)
2174 EmitVTableAssumptionLoads(ClassDecl, This);
2184 if (InheritedFromVBase &&
2185 CGM.getTarget().getCXXABI().hasConstructorVariants()) {
2190 Args.push_back(ThisArg);
2191 }
else if (!CXXInheritedCtorInitExprArgs.empty()) {
2193 assert(CXXInheritedCtorInitExprArgs.size() >= D->
getNumParams() &&
2194 "wrong number of parameters for inherited constructor call");
2195 Args = CXXInheritedCtorInitExprArgs;
2199 Args.push_back(ThisArg);
2200 const auto *OuterCtor = cast<CXXConstructorDecl>(CurCodeDecl);
2201 assert(OuterCtor->getNumParams() == D->
getNumParams());
2202 assert(!OuterCtor->isVariadic() &&
"should have been inlined");
2204 for (
const auto *Param : OuterCtor->parameters()) {
2206 OuterCtor->getParamDecl(Param->getFunctionScopeIndex())->getType(),
2208 EmitDelegateCallArg(Args, Param, E->
getLocation());
2211 if (Param->hasAttr<PassObjectSizeAttr>()) {
2212 auto *POSParam = SizeArguments[Param];
2213 assert(POSParam &&
"missing pass_object_size value for forwarding");
2214 EmitDelegateCallArg(Args, POSParam, E->
getLocation());
2219 EmitCXXConstructorCall(D,
Ctor_Base, ForVirtualBase,
false,
2233 CXXInheritedCtorInitExprArgs = Args;
2236 QualType RetType = BuildFunctionArgList(CurGD, Params);
2240 CGM.getCXXABI().addImplicitConstructorArgs(*
this, Ctor, CtorType,
2241 ForVirtualBase, Delegating, Args);
2244 assert(Args.size() >= Params.size() &&
"too few arguments for call");
2245 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
2246 if (I < Params.size() && isa<ImplicitParamDecl>(Params[I])) {
2247 const RValue &RV = Args[I].getRValue(*
this);
2248 assert(!RV.
isComplex() &&
"complex indirect params not supported");
2252 EmitParmDecl(*Params[I], Val, I + 1);
2260 ReturnValue = CreateIRTemp(RetType,
"retval.inhctor");
2262 CGM.getCXXABI().EmitInstanceFunctionProlog(*
this);
2263 CXXThisValue = CXXABIThisValue;
2266 EmitCtorPrologue(Ctor, CtorType, Params);
2278 if (!NonVirtualOffset.
isZero())
2286 Builder.CreateICmpEQ(VPtrValue, VTableGlobal,
"cmp.vtables");
2287 Builder.CreateAssumption(Cmp);
2292 if (CGM.getCXXABI().doStructorsInitializeVPtrs(ClassDecl))
2293 for (
const VPtr &Vptr : getVTablePointers(ClassDecl))
2294 EmitVTableAssumptionLoad(Vptr, This);
2311 Src = Builder.CreateBitCast(Src, t);
2331 FunctionArgList::const_iterator I = Args.begin(), E = Args.end();
2332 assert(I != E &&
"no parameters to constructor");
2335 Address This = LoadCXXThisAddress();
2341 if (CGM.getCXXABI().NeedsVTTParameter(CurGD)) {
2342 assert(I != E &&
"cannot skip vtt parameter, already done with args");
2343 assert((*I)->getType()->isPointerType() &&
2344 "skipping parameter not of vtt type");
2349 for (; I != E; ++I) {
2352 EmitDelegateCallArg(DelegateArgs, param, Loc);
2355 EmitCXXConstructorCall(Ctor, CtorType,
false,
2356 true, This, DelegateArgs,
2369 : Dtor(D), Addr(Addr),
Type(Type) {}
2374 QualType ThisTy = Dtor->getThisObjectType();
2376 true, Addr, ThisTy);
2386 Address ThisPtr = LoadCXXThisAddress();
2401 if (CGM.getLangOpts().Exceptions && !ClassDecl->hasTrivialDestructor()) {
2405 EHStack.pushCleanup<CallDelegatingCtorDtor>(
EHCleanup,
2406 ClassDecl->getDestructor(),
2413 bool ForVirtualBase,
2414 bool Delegating,
Address This,
2416 CGM.getCXXABI().EmitDestructorCall(*
this, DD, Type, ForVirtualBase,
2417 Delegating, This, ThisTy);
2427 : Dtor(D), Addr(Addr), Ty(Ty) {}
2444 if (!ClassDecl)
return;
2448 assert(D && D->
isUsed() &&
"destructor not marked as used!");
2449 PushDestructorCleanup(D, T, Addr);
2455 CGM.getCXXABI().getVTableAddressPointInStructor(
2458 if (!VTableAddressPoint)
2465 if (CGM.getCXXABI().isVirtualOffsetNeededForVTableField(*
this, Vptr)) {
2469 VirtualOffset = CGM.getCXXABI().GetVirtualBaseClassOffset(
2478 Address VTableField = LoadCXXThisAddress();
2480 if (!NonVirtualOffset.
isZero() || VirtualOffset)
2482 *
this, VTableField, NonVirtualOffset, VirtualOffset, Vptr.
VTableClass,
2488 llvm::FunctionType::get(CGM.Int32Ty,
true)
2491 VTableField = Builder.CreateBitCast(VTableField, VTablePtrTy->getPointerTo());
2492 VTableAddressPoint = Builder.CreateBitCast(VTableAddressPoint, VTablePtrTy);
2494 llvm::StoreInst *
Store = Builder.CreateStore(VTableAddressPoint, VTableField);
2495 TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTablePtrTy);
2496 CGM.DecorateInstructionWithTBAA(Store, TBAAInfo);
2497 if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
2498 CGM.getCodeGenOpts().StrictVTablePointers)
2499 CGM.DecorateInstructionWithInvariantGroup(Store, Vptr.
VTableClass);
2509 false, VTableClass, VBases,
2517 bool BaseIsNonVirtualPrimaryBase,
2523 if (!BaseIsNonVirtualPrimaryBase) {
2525 VPtr Vptr = {Base, NearestVBase, OffsetFromNearestVBase, VTableClass};
2526 Vptrs.push_back(Vptr);
2532 for (
const auto &I : RD->
bases()) {
2534 = cast<CXXRecordDecl>(I.getType()->getAs<
RecordType>()->getDecl());
2542 bool BaseDeclIsNonVirtualPrimaryBase;
2544 if (I.isVirtual()) {
2546 if (!VBases.insert(BaseDecl).second)
2554 BaseDeclIsNonVirtualPrimaryBase =
false;
2559 BaseOffsetFromNearestVBase =
2561 BaseDeclIsNonVirtualPrimaryBase = Layout.
getPrimaryBase() == BaseDecl;
2566 I.isVirtual() ? BaseDecl : NearestVBase, BaseOffsetFromNearestVBase,
2567 BaseDeclIsNonVirtualPrimaryBase, VTableClass, VBases, Vptrs);
2577 if (CGM.getCXXABI().doStructorsInitializeVPtrs(RD))
2578 for (
const VPtr &Vptr : getVTablePointers(RD))
2579 InitializeVTablePointer(Vptr);
2582 CGM.getCXXABI().initializeHiddenVirtualInheritanceMembers(*
this, RD);
2588 Address VTablePtrSrc = Builder.CreateElementBitCast(This, VTableTy);
2589 llvm::Instruction *VTable = Builder.CreateLoad(VTablePtrSrc,
"vtable");
2590 TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTableTy);
2591 CGM.DecorateInstructionWithTBAA(VTable, TBAAInfo);
2593 if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
2594 CGM.getCodeGenOpts().StrictVTablePointers)
2595 CGM.DecorateInstructionWithInvariantGroup(VTable, RD);
2621 if (MD->isVirtual()) {
2625 if (isa<CXXDestructorDecl>(MD) && MD->isImplicit())
2638 if (SanOpts.has(SanitizerKind::CFIVCall))
2640 else if (CGM.getCodeGenOpts().WholeProgramVTables &&
2641 CGM.HasHiddenLTOVisibility(RD)) {
2642 llvm::Metadata *MD =
2645 llvm::MetadataAsValue::get(CGM.getLLVMContext(), MD);
2649 Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::type_test),
2650 {CastedVTable, TypeId});
2651 Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::assume), TypeTest);
2659 if (!SanOpts.has(SanitizerKind::CFICastStrict))
2662 EmitVTablePtrCheck(RD, VTable, TCK, Loc);
2677 const CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(ClassTy->getDecl());
2682 if (!SanOpts.has(SanitizerKind::CFICastStrict))
2685 llvm::BasicBlock *ContBlock =
nullptr;
2689 Builder.CreateIsNotNull(Derived,
"cast.nonnull");
2691 llvm::BasicBlock *CheckBlock = createBasicBlock(
"cast.check");
2692 ContBlock = createBasicBlock(
"cast.cont");
2694 Builder.CreateCondBr(DerivedNotNull, CheckBlock, ContBlock);
2696 EmitBlock(CheckBlock);
2700 std::tie(VTable, ClassDecl) = CGM.getCXXABI().LoadVTablePtr(
2703 EmitVTablePtrCheck(ClassDecl, VTable, TCK, Loc);
2706 Builder.CreateBr(ContBlock);
2707 EmitBlock(ContBlock);
2715 if (!CGM.getCodeGenOpts().SanitizeCfiCrossDso &&
2716 !CGM.HasHiddenLTOVisibility(RD))
2720 llvm::SanitizerStatKind SSK;
2723 M = SanitizerKind::CFIVCall;
2724 SSK = llvm::SanStat_CFI_VCall;
2727 M = SanitizerKind::CFINVCall;
2728 SSK = llvm::SanStat_CFI_NVCall;
2730 case CFITCK_DerivedCast:
2731 M = SanitizerKind::CFIDerivedCast;
2732 SSK = llvm::SanStat_CFI_DerivedCast;
2734 case CFITCK_UnrelatedCast:
2735 M = SanitizerKind::CFIUnrelatedCast;
2736 SSK = llvm::SanStat_CFI_UnrelatedCast;
2739 case CFITCK_NVMFCall:
2740 case CFITCK_VMFCall:
2741 llvm_unreachable(
"unexpected sanitizer kind");
2745 if (
getContext().getSanitizerBlacklist().isBlacklistedType(M, TypeName))
2749 EmitSanitizerStatReport(SSK);
2751 llvm::Metadata *MD =
2757 CGM.getIntrinsic(llvm::Intrinsic::type_test), {CastedVTable, TypeId});
2759 llvm::Constant *StaticData[] = {
2760 llvm::ConstantInt::get(
Int8Ty, TCK),
2761 EmitCheckSourceLocation(Loc),
2765 auto CrossDsoTypeId = CGM.CreateCrossDsoCfiTypeId(MD);
2766 if (CGM.getCodeGenOpts().SanitizeCfiCrossDso && CrossDsoTypeId) {
2767 EmitCfiSlowPathCheck(M, TypeTest, CrossDsoTypeId, CastedVTable, StaticData);
2771 if (CGM.getCodeGenOpts().SanitizeTrap.has(M)) {
2772 EmitTrapCheck(TypeTest);
2776 llvm::Value *AllVtables = llvm::MetadataAsValue::get(
2777 CGM.getLLVMContext(),
2778 llvm::MDString::get(CGM.getLLVMContext(),
"all-vtables"));
2780 CGM.getIntrinsic(llvm::Intrinsic::type_test), {CastedVTable, AllVtables});
2781 EmitCheck(std::make_pair(TypeTest, M), SanitizerHandler::CFICheckFail,
2782 StaticData, {CastedVTable, ValidVtable});
2786 if (!CGM.getCodeGenOpts().WholeProgramVTables ||
2787 !SanOpts.has(SanitizerKind::CFIVCall) ||
2788 !CGM.getCodeGenOpts().SanitizeTrap.has(SanitizerKind::CFIVCall) ||
2789 !CGM.HasHiddenLTOVisibility(RD))
2794 SanitizerKind::CFIVCall, TypeName);
2801 EmitSanitizerStatReport(llvm::SanStat_CFI_VCall);
2803 llvm::Metadata *MD =
2805 llvm::Value *TypeId = llvm::MetadataAsValue::get(CGM.getLLVMContext(), MD);
2809 CGM.getIntrinsic(llvm::Intrinsic::type_checked_load),
2810 {CastedVTable, llvm::ConstantInt::get(
Int32Ty, VTableByteOffset),
2812 llvm::Value *CheckResult = Builder.CreateExtractValue(CheckedLoad, 1);
2814 EmitCheck(std::make_pair(CheckResult, SanitizerKind::CFIVCall),
2815 SanitizerHandler::CFICheckFail,
nullptr,
nullptr);
2817 return Builder.CreateBitCast(
2818 Builder.CreateExtractValue(CheckedLoad, 0),
2819 cast<llvm::PointerType>(VTable->getType())->getElementType());
2827 CGM.getTypes().arrangeCXXMethodDeclaration(callOperator);
2828 llvm::Constant *calleePtr =
2829 CGM.GetAddrOfFunction(
GlobalDecl(callOperator),
2830 CGM.getTypes().GetFunctionType(calleeFnInfo));
2837 if (!resultType->isVoidType() &&
2840 returnSlot =
ReturnValueSlot(ReturnValue, resultType.isVolatileQualified());
2848 RValue RV = EmitCall(calleeFnInfo, callee, returnSlot, callArgs);
2851 if (!resultType->isVoidType() && returnSlot.
isNull()) {
2852 if (
getLangOpts().ObjCAutoRefCount && resultType->isObjCRetainableType()) {
2855 EmitReturnOfRValue(RV, resultType);
2857 EmitBranchThroughCleanup(ReturnBlock);
2861 const BlockDecl *BD = BlockInfo->getBlockDecl();
2870 CGM.ErrorUnsupported(CurCodeDecl,
"lambda conversion to variadic function");
2878 Address ThisPtr = GetAddrOfBlockDecl(variable);
2883 EmitDelegateCallArg(CallArgs, param, param->getBeginLoc());
2886 "generic lambda interconversion to block not implemented");
2887 EmitForwardingCallToLambda(CallOp, CallArgs);
2902 EmitDelegateCallArg(CallArgs, Param, Param->getBeginLoc());
2911 void *InsertPos =
nullptr;
2914 assert(CorrespondingCallOpSpecialization);
2915 CallOp = cast<CXXMethodDecl>(CorrespondingCallOpSpecialization);
2917 EmitForwardingCallToLambda(CallOp, CallArgs);
2924 CGM.ErrorUnsupported(MD,
"lambda conversion to variadic function");
2928 EmitLambdaDelegatingInvokeBody(MD);
bool isBaseInitializer() const
Determine whether this initializer is initializing a base class.
ReturnValueSlot - Contains the address where the return value of a function can be stored...
void EnterDtorCleanups(const CXXDestructorDecl *Dtor, CXXDtorType Type)
EnterDtorCleanups - Enter the cleanups necessary to complete the given phase of destruction for a des...
Represents a function declaration or definition.
LValue MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T)
Given a value of type T* that may not be to a complete object, construct an l-value with the natural ...
Address getAddress() const
Expr * getInit() const
Get the initializer.
void EmitDelegateCXXConstructorCall(const CXXConstructorDecl *Ctor, CXXCtorType CtorType, const FunctionArgList &Args, SourceLocation Loc)
A (possibly-)qualified type.
const CGBitFieldInfo & getBitFieldInfo(const FieldDecl *FD) const
Return the BitFieldInfo that corresponds to the field FD.
Address EmitCXXMemberDataPointerAddress(const Expr *E, Address base, llvm::Value *memberPtr, const MemberPointerType *memberPtrType, LValueBaseInfo *BaseInfo=nullptr, TBAAAccessInfo *TBAAInfo=nullptr)
Emit the address of a field using a member data pointer.
void EmitCtorPrologue(const CXXConstructorDecl *CD, CXXCtorType Type, FunctionArgList &Args)
EmitCtorPrologue - This routine generates necessary code to initialize base classes and non-static da...
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
CodeGenTypes & getTypes()
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
unsigned getNumBases() const
Retrieves the number of base classes of this class.
CGRecordLayout - This class handles struct and union layout info while lowering AST types to LLVM typ...
bool isBlacklistedType(SanitizerMask Mask, StringRef MangledTypeName, StringRef Category=StringRef()) const
FunctionDecl * findSpecialization(ArrayRef< TemplateArgument > Args, void *&InsertPos)
Return the specialization with the provided arguments if it exists, otherwise return the insertion po...
capture_const_iterator capture_begin() const
llvm::LLVMContext & getLLVMContext()
CharUnits getClassPointerAlignment(const CXXRecordDecl *CD)
Returns the assumed alignment of an opaque pointer to the given class.
const ASTRecordLayout & getASTRecordLayout(const RecordDecl *D) const
Get or compute information about the layout of the specified record (struct/union/class) D...
Stmt - This represents one statement.
Address GetAddressOfDirectBaseInCompleteClass(Address Value, const CXXRecordDecl *Derived, const CXXRecordDecl *Base, bool BaseIsVirtual)
GetAddressOfBaseOfCompleteClass - Convert the given pointer to a complete class to the given direct b...
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
CharUnits getBaseClassOffset(const CXXRecordDecl *Base) const
getBaseClassOffset - Get the offset, in chars, for the given base class.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
QualType getThisType() const
Return the type of the this pointer.
Address GetAddressOfDerivedClass(Address Value, const CXXRecordDecl *Derived, CastExpr::path_const_iterator PathBegin, CastExpr::path_const_iterator PathEnd, bool NullCheckValue)
Checking the 'this' pointer for a constructor call.
const Type * getTypeForDecl() const
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
Defines the C++ template declaration subclasses.
void EmitLambdaStaticInvokeBody(const CXXMethodDecl *MD)
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
llvm::Value * LoadCXXThis()
LoadCXXThis - Load the value of 'this'.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined...
static bool isMemcpyEquivalentSpecialMember(const CXXMethodDecl *D)
The base class of the type hierarchy.
Expr * getOperatorDeleteThisArg() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Represents a call to a C++ constructor.
bool isZero() const
isZero - Test whether the quantity equals zero.
SourceLocation getEndLoc() const LLVM_READONLY
CharUnits getAlignment() const
getAlignment - Get the record alignment in characters.
LValue EmitLValueForFieldInitialization(LValue Base, const FieldDecl *Field)
EmitLValueForFieldInitialization - Like EmitLValueForField, except that if the Field is a reference...
llvm::IntegerType * Int8Ty
i8, i16, i32, and i64
Represents a C++ constructor within a class.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
bool isIndirectMemberInitializer() const
const CXXBaseSpecifier *const * path_const_iterator
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
Represents a variable declaration or definition.
RAII object to set/unset CodeGenFunction::IsSanitizerScope.
const T * getAs() const
Member-template getAs<specific type>'.
AggValueSlot::Overlap_t getOverlapForFieldInit(const FieldDecl *FD)
Determine whether a field initialization may overlap some other object.
const void * Store
Store - This opaque type encapsulates an immutable mapping from locations to values.
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type, bool ForVirtualBase, bool Delegating, Address This, QualType ThisTy)
llvm::Value * GetVTTParameter(GlobalDecl GD, bool ForVirtualBase, bool Delegating)
GetVTTParameter - Return the VTT parameter that should be passed to a base constructor/destructor wit...
llvm::Value * getPointer() const
void emitImplicitAssignmentOperatorBody(FunctionArgList &Args)
The collection of all-type qualifiers we support.
void add(RValue rvalue, QualType type)
bool mayInsertExtraPadding(bool EmitRemark=false) const
Whether we are allowed to insert extra padding between fields.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
CharUnits getBaseOffset() const
getBaseOffset - Returns the base class offset.
static const CXXRecordDecl * LeastDerivedClassWithSameLayout(const CXXRecordDecl *RD)
const TargetInfo & getTarget() const
bool usesInAlloca() const
Return true if this function uses inalloca arguments.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
void emitDestroy(Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
emitDestroy - Immediately perform the destruction of the given object.
Address getAddress() const
Indirect - Pass the argument indirectly via a hidden pointer with the specified alignment (0 indicate...
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool hasTrivialBody() const
Returns whether the function has a trivial body that does not require any specific codegen...
const CXXRecordDecl * NearestVBase
llvm::SmallPtrSet< const CXXRecordDecl *, 4 > VisitedVirtualBasesSetTy
void EmitSynthesizedCXXCopyCtorCall(const CXXConstructorDecl *D, Address This, Address Src, const CXXConstructExpr *E)
field_range fields() const
bool isVolatileQualified() const
Represents a member of a struct/union/class.
bool ShouldEmitVTableTypeCheckedLoad(const CXXRecordDecl *RD)
Returns whether we should perform a type checked load when loading a virtual function for virtual cal...
llvm::IntegerType * SizeTy
bool isReferenceType() const
void pushEHDestroy(QualType::DestructionKind dtorKind, Address addr, QualType type)
pushEHDestroy - Push the standard destructor for the given type as an EH-only cleanup.
void EmitVTablePtrCheck(const CXXRecordDecl *RD, llvm::Value *VTable, CFITypeCheckKind TCK, SourceLocation Loc)
EmitVTablePtrCheck - Emit a check that VTable is a valid virtual table for RD using llvm...
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
static AggValueSlot forAddr(Address addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
forAddr - Make a slot for an aggregate value.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
CharUnits getVBaseClassOffset(const CXXRecordDecl *VBase) const
getVBaseClassOffset - Get the offset, in chars, for the given base class.
void EmitLambdaDelegatingInvokeBody(const CXXMethodDecl *MD)
ArrayRef< ParmVarDecl * > parameters() const
void EmitInitializerForField(FieldDecl *Field, LValue LHS, Expr *Init)
CharUnits getDynamicOffsetAlignment(CharUnits ActualAlign, const CXXRecordDecl *Class, CharUnits ExpectedTargetAlign)
Given a class pointer with an actual known alignment, and the expected alignment of an object at a dy...
void EmitInheritedCXXConstructorCall(const CXXConstructorDecl *D, bool ForVirtualBase, Address This, bool InheritedFromVBase, const CXXInheritedCtorInitExpr *E)
Emit a call to a constructor inherited from a base class, passing the current constructor's arguments...
void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D, const ArrayType *ArrayTy, Address ArrayPtr, const CXXConstructExpr *E, bool NewPointerIsChecked, bool ZeroInitialization=false)
EmitCXXAggrConstructorCall - Emit a loop to call a particular constructor for each of several members...
bool isBitField() const
Determines whether this field is a bitfield.
bool isDelegatingConstructor() const
Determine whether this constructor is a delegating constructor.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
bool isBaseVirtual() const
Returns whether the base is virtual or not.
CharUnits - This is an opaque type for sizes expressed in character units.
void EmitTypeMetadataCodeForVCall(const CXXRecordDecl *RD, llvm::Value *VTable, SourceLocation Loc)
If whole-program virtual table optimization is enabled, emit an assumption that VTable is a member of...
bool isTriviallyCopyableType(const ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
CharUnits StorageOffset
The offset of the bitfield storage from the start of the struct.
ArrayRef< NamedDecl * > chain() const
unsigned char PointerWidthInBits
The width of a pointer into the generic address space.
CharUnits getAlignment() const
Return the alignment of this pointer.
llvm::PointerType * VoidPtrTy
A builtin binary operation expression such as "x + y" or "x <= y".
bool needsEHCleanup(QualType::DestructionKind kind)
Determines whether an EH cleanup is required to destroy a type with the given destruction kind...
CXXCtorType getCtorType() const
const CGFunctionInfo & arrangeCXXConstructorCall(const CallArgList &Args, const CXXConstructorDecl *D, CXXCtorType CtorKind, unsigned ExtraPrefixArgs, unsigned ExtraSuffixArgs, bool PassProtoArgs=true)
Arrange a call to a C++ method, passing the given arguments.
LangAS getAddressSpace() const
llvm::CallInst * CreateMemCpy(Address Dest, Address Src, llvm::Value *Size, bool IsVolatile=false)
const Type * getClass() const
Scope - A scope is a transient data structure that is used while parsing the program.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
void EmitDeleteCall(const FunctionDecl *DeleteFD, llvm::Value *Ptr, QualType DeleteTy, llvm::Value *NumElements=nullptr, CharUnits CookieSize=CharUnits())
param_type_iterator param_type_begin() const
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
bool isAnyMemberInitializer() const
base_class_iterator bases_begin()
void ForceCleanup(std::initializer_list< llvm::Value **> ValuesToReload={})
Force the emission of cleanups now, instead of waiting until this object is destroyed.
FieldDecl * getAnyMember() const
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
CharUnits getPointerAlign() const
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
bool isAbstract() const
Determine whether this class has a pure virtual function.
static bool BaseInitializerUsesThis(ASTContext &C, const Expr *Init)
Address getAggregateAddress() const
getAggregateAddr() - Return the Value* of the address of the aggregate.
init_iterator init_begin()
Retrieve an iterator to the first initializer.
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
Represents the this expression in C++.
LValue EmitLValueForField(LValue Base, const FieldDecl *Field)
CanQualType getReturnType() const
static CharUnits One()
One - Construct a CharUnits quantity of one.
CompoundStmt - This represents a group of statements like { stmt stmt }.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
ASTContext & getContext() const
Represents a prototype with parameter type info, e.g.
bool isDynamicClass() const
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static void EmitLValueForAnyFieldInitialization(CodeGenFunction &CGF, CXXCtorInitializer *MemberInit, LValue &LHS)
CXXCtorInitializer *const * init_const_iterator
Iterates through the member/base initializer list.
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
llvm::Value * GetVTablePtr(Address This, llvm::Type *VTableTy, const CXXRecordDecl *VTableClass)
GetVTablePtr - Return the Value of the vtable pointer member pointed to by This.
CXXDtorType
C++ destructor types.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
This represents one expression.
bool isCopyOrMoveConstructor(unsigned &TypeQuals) const
Determine whether this is a copy or move constructor.
bool isVariadic() const
Whether this function is variadic.
bool isDefaulted() const
Whether this function is defaulted per C++0x.
Qualifiers getQualifiers() const
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
void EmitVTableAssumptionLoad(const VPtr &vptr, Address This)
Emit assumption that vptr load == global vtable.
const T * castAs() const
Member-template castAs<specific type>.
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
Represents a C++ destructor within a class.
bool isSanitizerChecked() const
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
void EmitLambdaBlockInvokeBody()
llvm::PointerType * getType() const
Return the type of the pointer value.
const CXXRecordDecl * getPrimaryBase() const
getPrimaryBase - Get the primary base for this record.
unsigned getFieldCount() const
getFieldCount - Get the number of fields in the layout.
void EmitAsanPrologueOrEpilogue(bool Prologue)
const AstTypeMatcher< ArrayType > arrayType
Matches all kinds of arrays.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
llvm::LLVMContext & getLLVMContext()
const CXXRecordDecl * getBase() const
getBase - Returns the base class declaration.
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
llvm::IntegerType * Int32Ty
void EmitConstructorBody(FunctionArgList &Args)
EmitConstructorBody - Emits the body of the current constructor.
CharUnits alignmentOfArrayElement(CharUnits elementSize) const
Given that this is the alignment of the first element of an array, return the minimum alignment of an...
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T)
QualType getRecordType(const RecordDecl *Decl) const
A scoped helper to set the current debug location to an inlined location.
void EmitForwardingCallToLambda(const CXXMethodDecl *LambdaCallOperator, CallArgList &CallArgs)
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
const TargetInfo & getTarget() const
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
const LangOptions & getLangOpts() const
ASTContext & getContext() const
The COMDAT used for dtors.
const SanitizerBlacklist & getSanitizerBlacklist() const
GlobalDecl - represents a global declaration.
std::pair< CharUnits, CharUnits > getTypeInfoDataSizeInChars(QualType T) const
void EmitCXXConstructorCall(const CXXConstructorDecl *D, CXXCtorType Type, bool ForVirtualBase, bool Delegating, AggValueSlot ThisAVS, const CXXConstructExpr *E)
The l-value was considered opaque, so the alignment was determined from a type.
RecordDecl * getDecl() const
static bool CanSkipVTablePointerInitialization(CodeGenFunction &CGF, const CXXDestructorDecl *Dtor)
CanSkipVTablePointerInitialization - Check whether we need to initialize any vtable pointers before c...
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
static void EmitBaseInitializer(CodeGenFunction &CGF, const CXXRecordDecl *ClassDecl, CXXCtorInitializer *BaseInit)
void set(SanitizerMask K, bool Value)
Enable or disable a certain (single) sanitizer.
Enumerates target-specific builtins in their own namespaces within namespace clang.
Address CreateBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
Represents a call to an inherited base class constructor from an inheriting constructor.
void PushDestructorCleanup(QualType T, Address Addr)
PushDestructorCleanup - Push a cleanup to call the complete-object destructor of an object of the giv...
Encodes a location in the source.
QualType getReturnType() const
LangAS getAddressSpace() const
Return the address space of this type.
Expr * getSubExpr() const
void EmitVTableAssumptionLoads(const CXXRecordDecl *ClassDecl, Address This)
Emit assumption load for all bases.
bool inheritingCtorHasParams(const InheritedConstructor &Inherited, CXXCtorType Type)
Determine if a C++ inheriting constructor should have parameters matching those of its inherited cons...
Represents a call to a member function that may be written either with member call syntax (e...
const Decl * getDecl() const
init_iterator init_end()
Retrieve an iterator past the last initializer.
A scoped helper to set the current debug location to the specified location or preferred location of ...
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Represents a static or instance method of a struct/union/class.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
void EmitStmt(const Stmt *S, ArrayRef< const Attr *> Attrs=None)
EmitStmt - Emit the code for the statement.
virtual size_t getSrcArgforCopyCtor(const CXXConstructorDecl *, FunctionArgList &Args) const =0
const ParmVarDecl * getParamDecl(unsigned i) const
SanitizerSet SanOpts
Sanitizers enabled for this function.
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
All available information about a concrete callee.
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
void EmitInlinedInheritingCXXConstructorCall(const CXXConstructorDecl *Ctor, CXXCtorType CtorType, bool ForVirtualBase, bool Delegating, CallArgList &Args)
Emit a call to an inheriting constructor (that is, one that invokes a constructor inherited from a ba...
CXXCtorType
C++ constructor types.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
std::pair< CharUnits, CharUnits > getTypeInfoInChars(const Type *T) const
SourceLocation getLocation() const LLVM_READONLY
void InitializeVTablePointer(const VPtr &vptr)
Initialize the vtable pointer of the given subobject.
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type, returning the result.
FunctionArgList - Type for representing both the decl and type of parameters to a function...
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
CGFunctionInfo - Class to encapsulate the information about a function definition.
CharUnits alignmentAtOffset(CharUnits offset) const
Given that this is a non-zero alignment value, what is the alignment at the given offset...
Dataflow Directional Tag Classes.
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
void EmitVTablePtrCheckForCast(QualType T, llvm::Value *Derived, bool MayBeNull, CFITypeCheckKind TCK, SourceLocation Loc)
Derived is the presumed address of an object of type T after a cast.
AggValueSlot::Overlap_t getOverlapForBaseInit(const CXXRecordDecl *RD, const CXXRecordDecl *BaseRD, bool IsVirtual)
Determine whether a base class initialization may overlap some other object.
static bool canEmitDelegateCallArgs(CodeGenFunction &CGF, const CXXConstructorDecl *Ctor, CXXCtorType Type, CallArgList &Args)
A scope within which we are constructing the fields of an object which might use a CXXDefaultInitExpr...
Represents a field injected from an anonymous union/struct into the parent scope. ...
SourceLocation getSourceLocation() const
Determine the source location of the initializer.
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
llvm::IntegerType * IntPtrTy
void EmitDelegatingCXXConstructorCall(const CXXConstructorDecl *Ctor, const FunctionArgList &Args)
bool areArgsDestroyedLeftToRightInCallee() const
Are arguments to a call destroyed left to right in the callee? This is a fundamental language change...
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined...
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
void InitializeVTablePointers(const CXXRecordDecl *ClassDecl)
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
bool hasObjCLifetime() const
static AggValueSlot forLValue(const LValue &LV, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
ConstEvaluatedExprVisitor - This class visits 'const Expr *'s.
CharUnits getVBaseAlignment(CharUnits DerivedAlign, const CXXRecordDecl *Derived, const CXXRecordDecl *VBase)
Returns the assumed alignment of a virtual base of a class.
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type. ...
JumpDest ReturnBlock
ReturnBlock - Unified return block.
const FunctionDecl * getOperatorDelete() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
CharUnits OffsetFromNearestVBase
CodeGenTypes & getTypes() const
Represents a C++ base or member initializer.
Address getBitFieldAddress() const
IndirectFieldDecl * getIndirectMember() const
llvm::Type * getElementType() const
Return the type of the values stored in this address.
uint64_t getCharWidth() const
Return the size of the character type, in bits.
llvm::PointerType * Int8PtrTy
QualType getThisObjectType() const
Return the type of the object pointed by this.
llvm::Constant * GetNonVirtualBaseClassOffset(const CXXRecordDecl *ClassDecl, CastExpr::path_const_iterator PathBegin, CastExpr::path_const_iterator PathEnd)
Returns the offset from a derived class to a class.
Expr * getArg(unsigned Arg)
Return the specified argument.
llvm::FunctionCallee CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeList ExtraAttrs=llvm::AttributeList(), bool Local=false)
Create or return a runtime function declaration with the specified type and name. ...
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
ABIArgInfo & getReturnInfo()
Represents a base class of a C++ class.
VPtrsVector getVTablePointers(const CXXRecordDecl *VTableClass)
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Address LoadCXXThisAddress()
A template argument list.
llvm::IntegerType * PtrDiffTy
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
Overlap_t mayOverlap() const
int64_t toBits(CharUnits CharSize) const
Convert a size in characters to a size in bits.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
static void EmitMemberInitializer(CodeGenFunction &CGF, const CXXRecordDecl *ClassDecl, CXXCtorInitializer *MemberInit, const CXXConstructorDecl *Constructor, FunctionArgList &Args)
Represents a C++ struct/union/class.
static Destroyer destroyCXXObject
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
static bool IsConstructorDelegationValid(const CXXConstructorDecl *Ctor)
Checks whether the given constructor is a valid subject for the complete-to-base constructor delegati...
CharUnits getNonVirtualSize() const
getNonVirtualSize - Get the non-virtual size (in chars) of an object, which is the size of the object...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
__DEVICE__ int min(int __a, int __b)
void EmitVTablePtrCheckForCall(const CXXRecordDecl *RD, llvm::Value *VTable, CFITypeCheckKind TCK, SourceLocation Loc)
EmitVTablePtrCheckForCall - Virtual method MD is being called via VTable.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
CharUnits computeNonVirtualBaseClassOffset(const CXXRecordDecl *DerivedClass, CastExpr::path_const_iterator Start, CastExpr::path_const_iterator End)
static bool isInitializerOfDynamicClass(const CXXCtorInitializer *BaseInit)
CGCXXABI & getCXXABI() const
std::string getQualifiedNameAsString() const
static Address ApplyNonVirtualAndVirtualOffset(CodeGenFunction &CGF, Address addr, CharUnits nonVirtualOffset, llvm::Value *virtualOffset, const CXXRecordDecl *derivedClass, const CXXRecordDecl *nearestVBase)
Struct with all information about dynamic [sub]class needed to set vptr.
void EmitAggregateCopy(LValue Dest, LValue Src, QualType EltTy, AggValueSlot::Overlap_t MayOverlap, bool isVolatile=false)
EmitAggregateCopy - Emit an aggregate copy.
static RValue get(llvm::Value *V)
ArrayRef< ParmVarDecl * > parameters() const
void EmitDestructorBody(FunctionArgList &Args)
EmitDestructorBody - Emits the body of the current destructor.
void EmitBranchThroughCleanup(JumpDest Dest)
EmitBranchThroughCleanup - Emit a branch from the current insert block through the normal cleanup han...
const CXXRecordDecl * VTableClass
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
LValue - This represents an lvalue references.
Information for lazily generating a cleanup.
static bool HasTrivialDestructorBody(ASTContext &Context, const CXXRecordDecl *BaseClassDecl, const CXXRecordDecl *MostDerivedClassDecl)
Notes how many arguments were added to the beginning (Prefix) and ending (Suffix) of an arg list...
const LangOptions & getLangOpts() const
unsigned getTargetAddressSpace(QualType T) const
llvm::CallInst * EmitNounwindRuntimeCall(llvm::FunctionCallee callee, const Twine &name="")
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
const CGRecordLayout & getCGRecordLayout(const RecordDecl *)
getCGRecordLayout - Return record layout info for the given record decl.
Address GetAddressOfBaseClass(Address Value, const CXXRecordDecl *Derived, CastExpr::path_const_iterator PathBegin, CastExpr::path_const_iterator PathEnd, bool NullCheckValue, SourceLocation Loc)
GetAddressOfBaseClass - This function will add the necessary delta to the load of 'this' and returns ...
CallArgList - Type for representing both the value and type of arguments in a call.
const LangOptions & getLangOpts() const
base_class_range vbases()
Represents the canonical version of C arrays with a specified constant size.
Declaration of a template function.
static bool FieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field)
llvm::Value * EmitVTableTypeCheckedLoad(const CXXRecordDecl *RD, llvm::Value *VTable, uint64_t VTableByteOffset)
Emit a type checked load from the given vtable.
QualType getPointeeType() const
Structure with information about how a bitfield should be accessed.
void Destroyer(CodeGenFunction &CGF, Address addr, QualType ty)
method_range methods() const
QualType getType() const
Retrieves the type of the base class.