28 #include "llvm/IR/Intrinsics.h" 29 #include "llvm/IR/Metadata.h" 30 #include "llvm/Transforms/Utils/SanitizerStats.h" 32 using namespace clang;
33 using namespace CodeGen;
50 return layout.getNonVirtualAlignment();
64 CharUnits expectedVBaseAlign = baseLayout.getNonVirtualAlignment();
77 return std::min(actualBaseAlign, expectedTargetAlign);
80 CharUnits expectedBaseAlign = baseLayout.getNonVirtualAlignment();
100 if (actualBaseAlign >= expectedBaseAlign) {
101 return expectedTargetAlign;
107 return std::min(actualBaseAlign, expectedTargetAlign);
111 assert(CurFuncDecl &&
"loading 'this' without a func declaration?");
112 assert(isa<CXXMethodDecl>(CurFuncDecl));
115 if (CXXThisAlignment.isZero()) {
119 auto RD = cast<CXXMethodDecl>(CurFuncDecl)->getParent();
120 CXXThisAlignment = CGM.getClassPointerAlignment(RD);
123 return Address(LoadCXXThis(), CXXThisAlignment);
137 CGM.getCXXABI().EmitMemberDataPointerAddress(*
this, E, base,
138 memberPtr, memberPtrType);
141 CharUnits memberAlign = getNaturalTypeAlignment(memberType, BaseInfo,
147 return Address(ptr, memberAlign);
160 assert(!Base->
isVirtual() &&
"Should not see virtual bases here!");
169 Offset += Layout.getBaseClassOffset(BaseDecl);
181 assert(PathBegin != PathEnd &&
"Base path should not be empty!");
191 return llvm::ConstantInt::get(PtrDiffTy, Offset.
getQuantity());
203 bool BaseIsVirtual) {
218 if (!Offset.isZero()) {
219 V = Builder.CreateElementBitCast(V,
Int8Ty);
220 V = Builder.CreateConstInBoundsByteGEP(V, Offset);
222 V = Builder.CreateElementBitCast(V, ConvertType(Base));
234 assert(!nonVirtualOffset.
isZero() || virtualOffset !=
nullptr);
238 if (!nonVirtualOffset.
isZero()) {
239 baseOffset = llvm::ConstantInt::get(CGF.
PtrDiffTy,
242 baseOffset = CGF.
Builder.CreateAdd(virtualOffset, baseOffset);
245 baseOffset = virtualOffset;
251 ptr = CGF.
Builder.CreateInBoundsGEP(ptr, baseOffset,
"add.ptr");
257 assert(nearestVBase &&
"virtual offset without vbase?");
259 derivedClass, nearestVBase);
265 return Address(ptr, alignment);
273 assert(PathBegin != PathEnd &&
"Base path should not be empty!");
282 if ((*Start)->isVirtual()) {
284 cast<CXXRecordDecl>((*Start)->getType()->getAs<
RecordType>()->getDecl());
291 CharUnits NonVirtualOffset = CGM.computeNonVirtualBaseClassOffset(
292 VBase ? VBase : Derived, Start, PathEnd);
297 if (VBase && Derived->
hasAttr<FinalAttr>()) {
300 NonVirtualOffset += vBaseOffset;
306 ConvertType((PathEnd[-1])->getType())->getPointerTo();
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) {}
496 DerivedClass, BaseClass,
510 DynamicThisUseChecker(
const ASTContext &C) : super(C), UsesThis(
false) {}
517 void VisitCXXThisExpr(
const CXXThisExpr *E) { UsesThis =
true; }
522 DynamicThisUseChecker Checker(C);
524 return Checker.UsesThis;
532 "Must have base initializer!");
543 if (CtorType ==
Ctor_Base && isBaseVirtual)
576 if (!(CD && CD->isCopyOrMoveConstructor()) &&
598 for (
const auto *I : IndirectField->
chain())
612 "Must have member initializer!");
613 assert(MemberInit->
getInit() &&
"Must have initializer!");
617 QualType FieldType = Field->getType();
645 unsigned SrcArgIndex =
670 switch (getEvaluationKind(FieldType)) {
673 EmitExprAsInit(Init, Field, LHS,
false);
676 EmitStoreThroughLValue(RHS, LHS);
680 EmitComplexExprIntoLValue(Init, LHS,
true);
689 overlapForFieldInit(Field),
693 EmitAggExpr(Init, Slot);
701 if (needsEHCleanup(dtorKind))
702 pushEHDestroy(dtorKind, LHS.
getAddress(), FieldType);
760 Prologue ? cast<CXXConstructorDecl>(CurGD.getDecl())->getParent()
761 : cast<CXXDestructorDecl>(CurGD.getDecl())->getParent();
764 struct SizeAndOffset {
769 unsigned PtrSize = CGM.getDataLayout().getPointerSizeInBits();
778 size_t NumFields = 0;
779 for (
const auto *Field : ClassDecl->
fields()) {
781 std::pair<CharUnits, CharUnits> FieldInfo =
784 assert(NumFields < SSV.size());
788 assert(NumFields == SSV.size());
789 if (SSV.size() <= 1)
return;
794 llvm::FunctionType *FTy =
795 llvm::FunctionType::get(CGM.VoidTy, Args,
false);
796 llvm::Constant *F = CGM.CreateRuntimeFunction(
797 FTy, Prologue ?
"__asan_poison_intra_object_redzone" 798 :
"__asan_unpoison_intra_object_redzone");
801 ThisPtr = Builder.CreatePtrToInt(ThisPtr, IntPtrTy);
805 for (
size_t i = 0; i < SSV.size(); i++) {
806 uint64_t AsanAlignment = 8;
807 uint64_t NextField = i == SSV.size() - 1 ? TypeSize : SSV[i + 1].Offset;
808 uint64_t PoisonSize = NextField - SSV[i].Offset - SSV[i].Size;
809 uint64_t EndOffset = SSV[i].Offset + SSV[i].Size;
810 if (PoisonSize < AsanAlignment || !SSV[i].Size ||
811 (NextField % AsanAlignment) != 0)
814 F, {Builder.CreateAdd(ThisPtr, Builder.getIntN(PtrSize, EndOffset)),
815 Builder.getIntN(PtrSize, PoisonSize)});
821 EmitAsanPrologueOrEpilogue(
true);
825 assert((CGM.getTarget().getCXXABI().hasConstructorVariants() ||
827 "can only generate complete ctor for this ABI");
831 if (CtorType ==
Ctor_Complete && IsConstructorDelegationValid(Ctor) &&
832 CGM.getTarget().getCXXABI().hasConstructorVariants()) {
839 assert(Definition == Ctor &&
"emitting wrong constructor body");
843 bool IsTryBody = (Body && isa<CXXTryStmt>(Body));
845 EnterCXXTryStmt(*cast<CXXTryStmt>(Body),
true);
847 incrementProfileCounter(Body);
856 EmitCtorPrologue(Ctor, CtorType, Args);
860 EmitStmt(cast<CXXTryStmt>(Body)->getTryBlock());
871 ExitCXXTryStmt(*cast<CXXTryStmt>(Body),
true);
879 class CopyingValueRepresentation {
882 : CGF(CGF), OldSanOpts(CGF.
SanOpts) {
886 ~CopyingValueRepresentation() {
896 class FieldMemcpyizer {
900 : CGF(CGF), ClassDecl(ClassDecl), SrcRec(SrcRec),
902 FirstField(
nullptr), LastField(
nullptr), FirstFieldOffset(0),
903 LastFieldOffset(0), LastAddedFieldIndex(0) {}
905 bool isMemcpyableField(
FieldDecl *F)
const {
922 CharUnits getMemcpySize(uint64_t FirstByteOffset)
const {
924 unsigned LastFieldSize =
925 LastField->isBitField()
926 ? LastField->getBitWidthValue(Ctx)
929 uint64_t MemcpySizeBits = LastFieldOffset + LastFieldSize -
942 uint64_t FirstByteOffset;
943 if (FirstField->isBitField()) {
951 FirstByteOffset = FirstFieldOffset;
954 CharUnits MemcpySize = getMemcpySize(FirstByteOffset);
970 FirstField =
nullptr;
979 llvm::PointerType *DPT = DestPtr.
getType();
981 llvm::Type::getInt8PtrTy(CGF.
getLLVMContext(), DPT->getAddressSpace());
984 llvm::PointerType *SPT = SrcPtr.
getType();
986 llvm::Type::getInt8PtrTy(CGF.
getLLVMContext(), SPT->getAddressSpace());
995 FirstFieldOffset = RecLayout.getFieldOffset(F->
getFieldIndex());
996 LastFieldOffset = FirstFieldOffset;
1006 "Cannot aggregate fields out of order.");
1012 uint64_t FOffset = RecLayout.getFieldOffset(F->
getFieldIndex());
1013 if (FOffset < FirstFieldOffset) {
1015 FirstFieldOffset = FOffset;
1016 }
else if (FOffset > LastFieldOffset) {
1018 LastFieldOffset = FOffset;
1026 uint64_t FirstFieldOffset, LastFieldOffset;
1027 unsigned LastAddedFieldIndex;
1030 class ConstructorMemcpyizer :
public FieldMemcpyizer {
1045 if (!MemcpyableCtor)
1048 assert(Field &&
"No field for member init.");
1059 if (!isMemcpyableField(Field))
1069 : FieldMemcpyizer(CGF, CD->
getParent(), getTrivialCopySource(CGF, CD, Args)),
1070 ConstructorDecl(CD),
1077 if (isMemberInitMemcpyable(MemberInit)) {
1078 AggregatedInits.push_back(MemberInit);
1079 addMemcpyableField(MemberInit->
getMember());
1081 emitAggregatedInits();
1083 ConstructorDecl, Args);
1087 void emitAggregatedInits() {
1088 if (AggregatedInits.size() <= 1) {
1091 if (!AggregatedInits.empty()) {
1092 CopyingValueRepresentation CVR(CGF);
1094 AggregatedInits[0], ConstructorDecl, Args);
1095 AggregatedInits.clear();
1101 pushEHDestructors();
1103 AggregatedInits.clear();
1106 void pushEHDestructors() {
1111 for (
unsigned i = 0; i < AggregatedInits.size(); ++i) {
1124 emitAggregatedInits();
1129 bool MemcpyableCtor;
1134 class AssignmentMemcpyizer :
public FieldMemcpyizer {
1139 if (!AssignmentsMemcpyable)
1143 if (BO->getOpcode() != BO_Assign)
1149 if (!Field || !isMemcpyableField(Field))
1151 Stmt *RHS = BO->getRHS();
1153 RHS = EC->getSubExpr();
1156 if (
MemberExpr *ME2 = dyn_cast<MemberExpr>(RHS)) {
1157 if (ME2->getMemberDecl() == Field)
1169 if (!Field || !isMemcpyableField(Field))
1172 if (!Arg0 || Field != dyn_cast<FieldDecl>(Arg0->
getMemberDecl()))
1175 }
else if (
CallExpr *CE = dyn_cast<CallExpr>(S)) {
1177 if (!FD || FD->
getBuiltinID() != Builtin::BI__builtin_memcpy)
1179 Expr *DstPtr = CE->getArg(0);
1181 DstPtr = DC->getSubExpr();
1183 if (!DUO || DUO->
getOpcode() != UO_AddrOf)
1189 if (!Field || !isMemcpyableField(Field))
1191 Expr *SrcPtr = CE->getArg(1);
1193 SrcPtr = SC->getSubExpr();
1195 if (!SUO || SUO->
getOpcode() != UO_AddrOf)
1198 if (!ME2 || Field != dyn_cast<FieldDecl>(ME2->
getMemberDecl()))
1206 bool AssignmentsMemcpyable;
1212 : FieldMemcpyizer(CGF, AD->
getParent(), Args[Args.size() - 1]),
1214 assert(Args.size() == 2);
1217 void emitAssignment(
Stmt *S) {
1220 addMemcpyableField(F);
1221 AggregatedStmts.push_back(S);
1223 emitAggregatedStmts();
1228 void emitAggregatedStmts() {
1229 if (AggregatedStmts.size() <= 1) {
1230 if (!AggregatedStmts.empty()) {
1231 CopyingValueRepresentation CVR(CGF);
1238 AggregatedStmts.clear();
1242 emitAggregatedStmts();
1249 const auto *BaseClassDecl =
1251 return BaseClassDecl->isDynamicClass();
1260 return EmitDelegatingCXXConstructorCall(CD, Args);
1267 llvm::BasicBlock *BaseCtorContinueBB =
nullptr;
1269 !CGM.getTarget().getCXXABI().hasConstructorVariants()) {
1272 BaseCtorContinueBB =
1273 CGM.getCXXABI().EmitCtorCompleteObjectHandler(*
this, ClassDecl);
1274 assert(BaseCtorContinueBB);
1279 for (; B != E && (*B)->isBaseInitializer() && (*B)->isBaseVirtual(); B++) {
1280 if (CGM.getCodeGenOpts().StrictVTablePointers &&
1281 CGM.getCodeGenOpts().OptimizationLevel > 0 &&
1283 CXXThisValue = Builder.CreateLaunderInvariantGroup(LoadCXXThis());
1287 if (BaseCtorContinueBB) {
1289 Builder.CreateBr(BaseCtorContinueBB);
1290 EmitBlock(BaseCtorContinueBB);
1294 for (; B != E && (*B)->isBaseInitializer(); B++) {
1295 assert(!(*B)->isBaseVirtual());
1297 if (CGM.getCodeGenOpts().StrictVTablePointers &&
1298 CGM.getCodeGenOpts().OptimizationLevel > 0 &&
1300 CXXThisValue = Builder.CreateLaunderInvariantGroup(LoadCXXThis());
1304 CXXThisValue = OldThis;
1306 InitializeVTablePointers(ClassDecl);
1310 ConstructorMemcpyizer CM(*
this, CD, Args);
1311 for (; B != E; B++) {
1315 "Delegating initializer on non-delegating constructor");
1316 CM.addMemberInitializer(Member);
1337 for (
const auto *Field : BaseClassDecl->
fields())
1342 for (
const auto &I : BaseClassDecl->
bases()) {
1347 cast<CXXRecordDecl>(I.getType()->castAs<
RecordType>()->getDecl());
1349 MostDerivedClassDecl))
1353 if (BaseClassDecl == MostDerivedClassDecl) {
1355 for (
const auto &I : BaseClassDecl->
vbases()) {
1357 cast<CXXRecordDecl>(I.getType()->castAs<
RecordType>()->getDecl());
1359 MostDerivedClassDecl))
1398 for (
const auto *Field : ClassDecl->
fields())
1416 llvm::CallInst *TrapCall = EmitTrapCall(llvm::Intrinsic::trap);
1417 TrapCall->setDoesNotReturn();
1418 TrapCall->setDoesNotThrow();
1419 Builder.CreateUnreachable();
1420 Builder.ClearInsertionPoint();
1426 incrementProfileCounter(Body);
1435 if (HaveInsertPoint())
1437 false, LoadCXXThisAddress());
1443 bool isTryBody = (Body && isa<CXXTryStmt>(Body));
1445 EnterCXXTryStmt(*cast<CXXTryStmt>(Body),
true);
1446 EmitAsanPrologueOrEpilogue(
false);
1457 case Dtor_Comdat: llvm_unreachable(
"not expecting a COMDAT");
1458 case Dtor_Deleting: llvm_unreachable(
"already handled deleting case");
1462 "can't emit a dtor without a body for non-Microsoft ABIs");
1468 EmitCXXDestructorCall(Dtor,
Dtor_Base,
false,
1469 false, LoadCXXThisAddress());
1486 if (CGM.getCodeGenOpts().StrictVTablePointers &&
1487 CGM.getCodeGenOpts().OptimizationLevel > 0)
1488 CXXThisValue = Builder.CreateLaunderInvariantGroup(LoadCXXThis());
1489 InitializeVTablePointers(Dtor->
getParent());
1493 EmitStmt(cast<CXXTryStmt>(Body)->getTryBlock());
1497 assert(Dtor->
isImplicit() &&
"bodyless dtor not implicit");
1503 CurFn->addFnAttr(llvm::Attribute::AlwaysInline);
1513 ExitCXXTryStmt(*cast<CXXTryStmt>(Body),
true);
1517 const CXXMethodDecl *AssignOp = cast<CXXMethodDecl>(CurGD.getDecl());
1519 assert(isa<CompoundStmt>(RootS) &&
1520 "Body of an implicit assignment operator should be compound stmt.");
1521 const CompoundStmt *RootCS = cast<CompoundStmt>(RootS);
1525 incrementProfileCounter(RootCS);
1526 AssignmentMemcpyizer AM(*
this, AssignOp, Args);
1527 for (
auto *I : RootCS->
body())
1528 AM.emitAssignment(I);
1548 LoadThisForDtorDelete(CGF, Dtor),
1555 bool ReturnAfterDelete) {
1559 = CGF.
Builder.CreateIsNull(ShouldDeleteCondition);
1560 CGF.
Builder.CreateCondBr(ShouldCallDelete, continueBB, callDeleteBB);
1566 LoadThisForDtorDelete(CGF, Dtor),
1569 ReturnAfterDelete &&
1570 "unexpected value for ReturnAfterDelete");
1571 if (ReturnAfterDelete)
1574 CGF.
Builder.CreateBr(continueBB);
1583 CallDtorDeleteConditional(
llvm::Value *ShouldDeleteCondition)
1584 : ShouldDeleteCondition(ShouldDeleteCondition) {
1585 assert(ShouldDeleteCondition !=
nullptr);
1589 EmitConditionalDtorDeleteCall(CGF, ShouldDeleteCondition,
1597 bool useEHCleanupForArray;
1601 bool useEHCleanupForArray)
1602 : field(field), destroyer(destroyer),
1603 useEHCleanupForArray(useEHCleanupForArray) {}
1614 flags.isForNormalCleanup() && useEHCleanupForArray);
1624 llvm::ConstantInt::get(CGF.
SizeTy, PoisonSize)};
1628 llvm::FunctionType *FnType =
1629 llvm::FunctionType::get(CGF.
VoidTy, ArgTypes,
false);
1653 CGF.
CurFn->addFnAttr(
"disable-tail-calls",
"true");
1658 unsigned fieldIndex = 0;
1659 int startIndex = -1;
1666 startIndex = fieldIndex;
1673 }
else if (startIndex >= 0) {
1675 PoisonMembers(CGF, startIndex, fieldIndex);
1689 unsigned layoutEndOffset) {
1694 llvm::ConstantInt *OffsetSizePtr = llvm::ConstantInt::get(
1716 if (PoisonSize == 0)
1719 EmitSanitizerDtorCallback(CGF, OffsetPtr, PoisonSize);
1741 EmitSanitizerDtorCallback(CGF, VTablePtr, PoisonSize);
1755 "Should not emit dtor epilogue for non-exported trivial dtor!");
1761 "operator delete missing - EnterDtorCleanups");
1762 if (CXXStructorImplicitParamValue) {
1766 EmitConditionalDtorDeleteCall(*
this, CXXStructorImplicitParamValue,
1769 EHStack.pushCleanup<CallDtorDeleteConditional>(
1775 LoadThisForDtorDelete(*
this, DD),
1777 EmitBranchThroughCleanup(ReturnBlock);
1795 if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor &&
1796 SanOpts.has(SanitizerKind::Memory) && ClassDecl->
getNumVBases() &&
1802 for (
const auto &
Base : ClassDecl->
vbases()) {
1804 = cast<CXXRecordDecl>(
Base.getType()->getAs<
RecordType>()->getDecl());
1821 if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor &&
1822 SanOpts.has(SanitizerKind::Memory) && !ClassDecl->
getNumVBases() &&
1827 for (
const auto &
Base : ClassDecl->
bases()) {
1829 if (
Base.isVirtual())
1845 if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor &&
1846 SanOpts.has(SanitizerKind::Memory))
1850 for (
const auto *Field : ClassDecl->
fields()) {
1853 if (!dtorKind)
continue;
1859 CleanupKind cleanupKind = getCleanupKind(dtorKind);
1860 EHStack.pushCleanup<DestroyField>(cleanupKind, Field,
1861 getDestroyer(dtorKind),
1877 bool zeroInitialize) {
1880 emitArrayLength(arrayType, elementType, arrayBegin);
1882 EmitCXXAggrConstructorCall(ctor, numElements, arrayBegin, E,
1883 NewPointerIsChecked, zeroInitialize);
1899 bool NewPointerIsChecked,
1900 bool zeroInitialize) {
1906 llvm::BranchInst *zeroCheckBranch =
nullptr;
1909 llvm::ConstantInt *constantCount
1910 = dyn_cast<llvm::ConstantInt>(numElements);
1911 if (constantCount) {
1913 if (constantCount->isZero())
return;
1917 llvm::BasicBlock *loopBB = createBasicBlock(
"new.ctorloop");
1918 llvm::Value *iszero = Builder.CreateIsNull(numElements,
"isempty");
1919 zeroCheckBranch = Builder.CreateCondBr(iszero, loopBB, loopBB);
1925 llvm::Value *arrayEnd = Builder.CreateInBoundsGEP(arrayBegin, numElements,
1929 llvm::BasicBlock *entryBB = Builder.GetInsertBlock();
1930 llvm::BasicBlock *loopBB = createBasicBlock(
"arrayctor.loop");
1932 llvm::PHINode *cur = Builder.CreatePHI(arrayBegin->getType(), 2,
1934 cur->addIncoming(arrayBegin, entryBB);
1952 EmitNullInitialization(curAddr, type);
1969 Destroyer *destroyer = destroyCXXObject;
1970 pushRegularPartialArrayCleanup(arrayBegin, cur, type, eltAlignment,
1981 Builder.CreateInBoundsGEP(cur, llvm::ConstantInt::get(
SizeTy, 1),
1983 cur->addIncoming(next, Builder.GetInsertBlock());
1986 llvm::Value *done = Builder.CreateICmpEQ(next, arrayEnd,
"arrayctor.done");
1987 llvm::BasicBlock *contBB = createBasicBlock(
"arrayctor.cont");
1988 Builder.CreateCondBr(done, contBB, loopBB);
1991 if (zeroCheckBranch) zeroCheckBranch->setSuccessor(0, contBB);
2002 assert(!dtor->isTrivial());
2009 bool ForVirtualBase,
2010 bool Delegating,
Address This,
2013 bool NewPointerIsChecked) {
2020 if (SlotAS != ThisAS) {
2023 ThisPtr->getType()->getPointerElementType()->getPointerTo(TargetThisAS);
2024 ThisPtr = getTargetHooks().performAddrSpaceCast(*
this, This.
getPointer(),
2025 ThisAS, SlotAS, NewType);
2034 assert(E->
getNumArgs() == 1 &&
"unexpected argcount for trivial ctor");
2037 LValue Src = EmitLValue(Arg);
2039 LValue Dest = MakeAddrLValue(This, DestTy);
2040 EmitAggregateCopyCtor(Dest, Src, Overlap);
2047 ? EvaluationOrder::ForceLeftToRight
2052 EmitCXXConstructorCall(D, Type, ForVirtualBase, Delegating, This, Args,
2053 Overlap, E->
getExprLoc(), NewPointerIsChecked);
2066 if (
P->getType().isDestructedType())
2082 bool ForVirtualBase,
2088 bool NewPointerIsChecked) {
2091 if (!NewPointerIsChecked)
2096 assert(Args.size() == 1 &&
"trivial default ctor with args");
2104 assert(Args.size() == 2 &&
"unexpected argcount for trivial ctor");
2107 Address Src(Args[1].getRValue(*this).getScalarVal(),
2108 getNaturalTypeAlignment(SrcTy));
2109 LValue SrcLVal = MakeAddrLValue(Src, SrcTy);
2111 LValue DestLVal = MakeAddrLValue(This, DestTy);
2112 EmitAggregateCopyCtor(DestLVal, SrcLVal, Overlap);
2116 bool PassPrototypeArgs =
true;
2121 EmitInlinedInheritingCXXConstructorCall(D, Type, ForVirtualBase,
2129 CGM.getCXXABI().addImplicitConstructorArgs(*
this, D, Type, ForVirtualBase,
2133 llvm::Constant *CalleePtr =
2135 const CGFunctionInfo &Info = CGM.getTypes().arrangeCXXConstructorCall(
2136 Args, D, Type, ExtraArgs.
Prefix, ExtraArgs.
Suffix, PassPrototypeArgs);
2151 if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
2153 CGM.getCXXABI().canSpeculativelyEmitVTable(ClassDecl) &&
2154 CGM.getCodeGenOpts().StrictVTablePointers)
2155 EmitVTableAssumptionLoads(ClassDecl, This);
2165 if (InheritedFromVBase &&
2166 CGM.getTarget().getCXXABI().hasConstructorVariants()) {
2171 Args.push_back(ThisArg);
2172 }
else if (!CXXInheritedCtorInitExprArgs.empty()) {
2174 assert(CXXInheritedCtorInitExprArgs.size() >= D->
getNumParams() &&
2175 "wrong number of parameters for inherited constructor call");
2176 Args = CXXInheritedCtorInitExprArgs;
2180 Args.push_back(ThisArg);
2181 const auto *OuterCtor = cast<CXXConstructorDecl>(CurCodeDecl);
2182 assert(OuterCtor->getNumParams() == D->
getNumParams());
2183 assert(!OuterCtor->isVariadic() &&
"should have been inlined");
2185 for (
const auto *Param : OuterCtor->parameters()) {
2187 OuterCtor->getParamDecl(Param->getFunctionScopeIndex())->getType(),
2189 EmitDelegateCallArg(Args, Param, E->
getLocation());
2192 if (Param->hasAttr<PassObjectSizeAttr>()) {
2193 auto *POSParam = SizeArguments[Param];
2194 assert(POSParam &&
"missing pass_object_size value for forwarding");
2195 EmitDelegateCallArg(Args, POSParam, E->
getLocation());
2200 EmitCXXConstructorCall(D,
Ctor_Base, ForVirtualBase,
false,
2214 CXXInheritedCtorInitExprArgs = Args;
2217 QualType RetType = BuildFunctionArgList(CurGD, Params);
2221 CGM.getCXXABI().addImplicitConstructorArgs(*
this, Ctor, CtorType,
2222 ForVirtualBase, Delegating, Args);
2225 assert(Args.size() >= Params.size() &&
"too few arguments for call");
2226 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
2227 if (I < Params.size() && isa<ImplicitParamDecl>(Params[I])) {
2228 const RValue &RV = Args[I].getRValue(*
this);
2229 assert(!RV.
isComplex() &&
"complex indirect params not supported");
2233 EmitParmDecl(*Params[I], Val, I + 1);
2241 ReturnValue = CreateIRTemp(RetType,
"retval.inhctor");
2243 CGM.getCXXABI().EmitInstanceFunctionProlog(*
this);
2244 CXXThisValue = CXXABIThisValue;
2247 EmitCtorPrologue(Ctor, CtorType, Params);
2259 if (!NonVirtualOffset.
isZero())
2267 Builder.CreateICmpEQ(VPtrValue, VTableGlobal,
"cmp.vtables");
2268 Builder.CreateAssumption(Cmp);
2273 if (CGM.getCXXABI().doStructorsInitializeVPtrs(ClassDecl))
2274 for (
const VPtr &Vptr : getVTablePointers(ClassDecl))
2275 EmitVTableAssumptionLoad(Vptr, This);
2291 llvm::Type *t = CGM.getTypes().ConvertType(QT);
2292 Src = Builder.CreateBitCast(Src, t);
2312 FunctionArgList::const_iterator I = Args.begin(), E = Args.end();
2313 assert(I != E &&
"no parameters to constructor");
2316 Address This = LoadCXXThisAddress();
2322 if (CGM.getCXXABI().NeedsVTTParameter(CurGD)) {
2323 assert(I != E &&
"cannot skip vtt parameter, already done with args");
2324 assert((*I)->getType()->isPointerType() &&
2325 "skipping parameter not of vtt type");
2330 for (; I != E; ++I) {
2333 EmitDelegateCallArg(DelegateArgs, param, Loc);
2336 EmitCXXConstructorCall(Ctor, CtorType,
false,
2337 true, This, DelegateArgs,
2350 : Dtor(D), Addr(Addr),
Type(Type) {}
2364 Address ThisPtr = LoadCXXThisAddress();
2379 if (CGM.getLangOpts().Exceptions && !ClassDecl->hasTrivialDestructor()) {
2383 EHStack.pushCleanup<CallDelegatingCtorDtor>(
EHCleanup,
2384 ClassDecl->getDestructor(),
2391 bool ForVirtualBase,
2394 CGM.getCXXABI().EmitDestructorCall(*
this, DD, Type, ForVirtualBase,
2404 : Dtor(D), Addr(Addr) {}
2421 if (!ClassDecl)
return;
2425 assert(D && D->
isUsed() &&
"destructor not marked as used!");
2426 PushDestructorCleanup(D, Addr);
2432 CGM.getCXXABI().getVTableAddressPointInStructor(
2435 if (!VTableAddressPoint)
2442 if (CGM.getCXXABI().isVirtualOffsetNeededForVTableField(*
this, Vptr)) {
2446 VirtualOffset = CGM.getCXXABI().GetVirtualBaseClassOffset(
2455 Address VTableField = LoadCXXThisAddress();
2457 if (!NonVirtualOffset.
isZero() || VirtualOffset)
2459 *
this, VTableField, NonVirtualOffset, VirtualOffset, Vptr.
VTableClass,
2465 llvm::FunctionType::get(CGM.Int32Ty,
true)
2468 VTableField = Builder.CreateBitCast(VTableField, VTablePtrTy->getPointerTo());
2469 VTableAddressPoint = Builder.CreateBitCast(VTableAddressPoint, VTablePtrTy);
2471 llvm::StoreInst *
Store = Builder.CreateStore(VTableAddressPoint, VTableField);
2472 TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTablePtrTy);
2473 CGM.DecorateInstructionWithTBAA(Store, TBAAInfo);
2474 if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
2475 CGM.getCodeGenOpts().StrictVTablePointers)
2476 CGM.DecorateInstructionWithInvariantGroup(Store, Vptr.
VTableClass);
2486 false, VTableClass, VBases,
2494 bool BaseIsNonVirtualPrimaryBase,
2500 if (!BaseIsNonVirtualPrimaryBase) {
2502 VPtr Vptr = {
Base, NearestVBase, OffsetFromNearestVBase, VTableClass};
2503 Vptrs.push_back(Vptr);
2509 for (
const auto &I : RD->
bases()) {
2511 = cast<CXXRecordDecl>(I.getType()->getAs<
RecordType>()->getDecl());
2519 bool BaseDeclIsNonVirtualPrimaryBase;
2521 if (I.isVirtual()) {
2523 if (!VBases.insert(BaseDecl).second)
2531 BaseDeclIsNonVirtualPrimaryBase =
false;
2536 BaseOffsetFromNearestVBase =
2538 BaseDeclIsNonVirtualPrimaryBase = Layout.
getPrimaryBase() == BaseDecl;
2543 I.isVirtual() ? BaseDecl : NearestVBase, BaseOffsetFromNearestVBase,
2544 BaseDeclIsNonVirtualPrimaryBase, VTableClass, VBases, Vptrs);
2554 if (CGM.getCXXABI().doStructorsInitializeVPtrs(RD))
2555 for (
const VPtr &Vptr : getVTablePointers(RD))
2556 InitializeVTablePointer(Vptr);
2559 CGM.getCXXABI().initializeHiddenVirtualInheritanceMembers(*
this, RD);
2565 Address VTablePtrSrc = Builder.CreateElementBitCast(This, VTableTy);
2566 llvm::Instruction *VTable = Builder.CreateLoad(VTablePtrSrc,
"vtable");
2567 TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTableTy);
2568 CGM.DecorateInstructionWithTBAA(VTable, TBAAInfo);
2570 if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
2571 CGM.getCodeGenOpts().StrictVTablePointers)
2572 CGM.DecorateInstructionWithInvariantGroup(VTable, RD);
2598 if (MD->isVirtual()) {
2602 if (isa<CXXDestructorDecl>(MD) && MD->isImplicit())
2615 if (SanOpts.has(SanitizerKind::CFIVCall))
2617 else if (CGM.getCodeGenOpts().WholeProgramVTables &&
2618 CGM.HasHiddenLTOVisibility(RD)) {
2619 llvm::Metadata *MD =
2622 llvm::MetadataAsValue::get(CGM.getLLVMContext(), MD);
2626 Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::type_test),
2627 {CastedVTable, TypeId});
2628 Builder.CreateCall(CGM.getIntrinsic(llvm::Intrinsic::assume), TypeTest);
2636 if (!SanOpts.has(SanitizerKind::CFICastStrict))
2639 EmitVTablePtrCheck(RD, VTable, TCK, Loc);
2654 const CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(ClassTy->getDecl());
2659 if (!SanOpts.has(SanitizerKind::CFICastStrict))
2662 llvm::BasicBlock *ContBlock =
nullptr;
2666 Builder.CreateIsNotNull(Derived,
"cast.nonnull");
2668 llvm::BasicBlock *CheckBlock = createBasicBlock(
"cast.check");
2669 ContBlock = createBasicBlock(
"cast.cont");
2671 Builder.CreateCondBr(DerivedNotNull, CheckBlock, ContBlock);
2673 EmitBlock(CheckBlock);
2677 std::tie(VTable, ClassDecl) = CGM.getCXXABI().LoadVTablePtr(
2680 EmitVTablePtrCheck(ClassDecl, VTable, TCK, Loc);
2683 Builder.CreateBr(ContBlock);
2684 EmitBlock(ContBlock);
2692 if (!CGM.getCodeGenOpts().SanitizeCfiCrossDso &&
2693 !CGM.HasHiddenLTOVisibility(RD))
2697 llvm::SanitizerStatKind SSK;
2700 M = SanitizerKind::CFIVCall;
2701 SSK = llvm::SanStat_CFI_VCall;
2704 M = SanitizerKind::CFINVCall;
2705 SSK = llvm::SanStat_CFI_NVCall;
2707 case CFITCK_DerivedCast:
2708 M = SanitizerKind::CFIDerivedCast;
2709 SSK = llvm::SanStat_CFI_DerivedCast;
2711 case CFITCK_UnrelatedCast:
2712 M = SanitizerKind::CFIUnrelatedCast;
2713 SSK = llvm::SanStat_CFI_UnrelatedCast;
2716 case CFITCK_NVMFCall:
2717 case CFITCK_VMFCall:
2718 llvm_unreachable(
"unexpected sanitizer kind");
2722 if (
getContext().getSanitizerBlacklist().isBlacklistedType(M, TypeName))
2726 EmitSanitizerStatReport(SSK);
2728 llvm::Metadata *MD =
2734 CGM.getIntrinsic(llvm::Intrinsic::type_test), {CastedVTable, TypeId});
2736 llvm::Constant *StaticData[] = {
2737 llvm::ConstantInt::get(
Int8Ty, TCK),
2738 EmitCheckSourceLocation(Loc),
2742 auto CrossDsoTypeId = CGM.CreateCrossDsoCfiTypeId(MD);
2743 if (CGM.getCodeGenOpts().SanitizeCfiCrossDso && CrossDsoTypeId) {
2744 EmitCfiSlowPathCheck(M, TypeTest, CrossDsoTypeId, CastedVTable, StaticData);
2748 if (CGM.getCodeGenOpts().SanitizeTrap.has(M)) {
2749 EmitTrapCheck(TypeTest);
2753 llvm::Value *AllVtables = llvm::MetadataAsValue::get(
2754 CGM.getLLVMContext(),
2755 llvm::MDString::get(CGM.getLLVMContext(),
"all-vtables"));
2757 CGM.getIntrinsic(llvm::Intrinsic::type_test), {CastedVTable, AllVtables});
2758 EmitCheck(std::make_pair(TypeTest, M), SanitizerHandler::CFICheckFail,
2759 StaticData, {CastedVTable, ValidVtable});
2763 if (!CGM.getCodeGenOpts().WholeProgramVTables ||
2764 !SanOpts.has(SanitizerKind::CFIVCall) ||
2765 !CGM.getCodeGenOpts().SanitizeTrap.has(SanitizerKind::CFIVCall) ||
2766 !CGM.HasHiddenLTOVisibility(RD))
2771 SanitizerKind::CFIVCall, TypeName);
2778 EmitSanitizerStatReport(llvm::SanStat_CFI_VCall);
2780 llvm::Metadata *MD =
2782 llvm::Value *TypeId = llvm::MetadataAsValue::get(CGM.getLLVMContext(), MD);
2786 CGM.getIntrinsic(llvm::Intrinsic::type_checked_load),
2787 {CastedVTable, llvm::ConstantInt::get(
Int32Ty, VTableByteOffset),
2789 llvm::Value *CheckResult = Builder.CreateExtractValue(CheckedLoad, 1);
2791 EmitCheck(std::make_pair(CheckResult, SanitizerKind::CFIVCall),
2792 SanitizerHandler::CFICheckFail,
nullptr,
nullptr);
2794 return Builder.CreateBitCast(
2795 Builder.CreateExtractValue(CheckedLoad, 0),
2796 cast<llvm::PointerType>(VTable->getType())->getElementType());
2804 CGM.getTypes().arrangeCXXMethodDeclaration(callOperator);
2805 llvm::Constant *calleePtr =
2806 CGM.GetAddrOfFunction(
GlobalDecl(callOperator),
2807 CGM.getTypes().GetFunctionType(calleeFnInfo));
2814 if (!resultType->isVoidType() &&
2817 returnSlot =
ReturnValueSlot(ReturnValue, resultType.isVolatileQualified());
2825 RValue RV = EmitCall(calleeFnInfo, callee, returnSlot, callArgs);
2828 if (!resultType->isVoidType() && returnSlot.
isNull()) {
2829 if (
getLangOpts().ObjCAutoRefCount && resultType->isObjCRetainableType()) {
2832 EmitReturnOfRValue(RV, resultType);
2834 EmitBranchThroughCleanup(ReturnBlock);
2838 const BlockDecl *BD = BlockInfo->getBlockDecl();
2847 CGM.ErrorUnsupported(CurCodeDecl,
"lambda conversion to variadic function");
2855 Address ThisPtr = GetAddrOfBlockDecl(variable);
2860 EmitDelegateCallArg(CallArgs, param, param->getBeginLoc());
2863 "generic lambda interconversion to block not implemented");
2864 EmitForwardingCallToLambda(CallOp, CallArgs);
2879 EmitDelegateCallArg(CallArgs, Param, Param->getBeginLoc());
2888 void *InsertPos =
nullptr;
2891 assert(CorrespondingCallOpSpecialization);
2892 CallOp = cast<CXXMethodDecl>(CorrespondingCallOpSpecialization);
2894 EmitForwardingCallToLambda(CallOp, CallArgs);
2901 CGM.ErrorUnsupported(MD,
"lambda conversion to variadic function");
2905 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 ...
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
Returns 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>'.
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. ...
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.
AggValueSlot::Overlap_t overlapForBaseInit(const CXXRecordDecl *RD, const CXXRecordDecl *BaseRD, bool IsVirtual)
Determine whether a base class initialization may overlap some other object.
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.
void EmitCXXConstructorCall(const CXXConstructorDecl *D, CXXCtorType Type, bool ForVirtualBase, bool Delegating, Address This, const CXXConstructExpr *E, AggValueSlot::Overlap_t Overlap, bool NewPointerIsChecked)
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.
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...
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)
llvm::Constant * CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeList ExtraAttrs=llvm::AttributeList(), bool Local=false)
Create a new runtime function with the specified type and name.
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.
llvm::CallInst * EmitNounwindRuntimeCall(llvm::Value *callee, const Twine &name="")
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.
AggValueSlot::Overlap_t overlapForFieldInit(const FieldDecl *FD)
Determine whether a field initialization may overlap some other object.
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.
Pepresents 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.
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 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
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.
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...
static void EmitBaseInitializer(CodeGenFunction &CGF, const CXXRecordDecl *ClassDecl, CXXCtorInitializer *BaseInit, CXXCtorType CtorType)
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.
void EmitCXXDestructorCall(const CXXDestructorDecl *D, CXXDtorType Type, bool ForVirtualBase, bool Delegating, Address This)
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.
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
Returns 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...
StructorType getFromCtorType(CXXCtorType T)
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
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.
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.
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.
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
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...
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.
__DEVICE__ int min(int __a, int __b)
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
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.