forked from OSchip/llvm-project
[clang] Remove Address::deprecated() from CGClass.cpp
This commit is contained in:
parent
9a40f9f681
commit
4cb24ef90a
|
@ -2691,8 +2691,7 @@ void CodeGenFunction::EmitVTablePtrCheckForCall(const CXXRecordDecl *RD,
|
|||
EmitVTablePtrCheck(RD, VTable, TCK, Loc);
|
||||
}
|
||||
|
||||
void CodeGenFunction::EmitVTablePtrCheckForCast(QualType T,
|
||||
llvm::Value *Derived,
|
||||
void CodeGenFunction::EmitVTablePtrCheckForCast(QualType T, Address Derived,
|
||||
bool MayBeNull,
|
||||
CFITypeCheckKind TCK,
|
||||
SourceLocation Loc) {
|
||||
|
@ -2715,7 +2714,7 @@ void CodeGenFunction::EmitVTablePtrCheckForCast(QualType T,
|
|||
|
||||
if (MayBeNull) {
|
||||
llvm::Value *DerivedNotNull =
|
||||
Builder.CreateIsNotNull(Derived, "cast.nonnull");
|
||||
Builder.CreateIsNotNull(Derived.getPointer(), "cast.nonnull");
|
||||
|
||||
llvm::BasicBlock *CheckBlock = createBasicBlock("cast.check");
|
||||
ContBlock = createBasicBlock("cast.cont");
|
||||
|
@ -2726,8 +2725,8 @@ void CodeGenFunction::EmitVTablePtrCheckForCast(QualType T,
|
|||
}
|
||||
|
||||
llvm::Value *VTable;
|
||||
std::tie(VTable, ClassDecl) = CGM.getCXXABI().LoadVTablePtr(
|
||||
*this, Address::deprecated(Derived, getPointerAlign()), ClassDecl);
|
||||
std::tie(VTable, ClassDecl) =
|
||||
CGM.getCXXABI().LoadVTablePtr(*this, Derived, ClassDecl);
|
||||
|
||||
EmitVTablePtrCheck(ClassDecl, VTable, TCK, Loc);
|
||||
|
||||
|
|
|
@ -1109,7 +1109,7 @@ Address CodeGenFunction::EmitPointerWithAlignment(const Expr *E,
|
|||
if (SanOpts.has(SanitizerKind::CFIUnrelatedCast) &&
|
||||
CE->getCastKind() == CK_BitCast) {
|
||||
if (auto PT = E->getType()->getAs<PointerType>())
|
||||
EmitVTablePtrCheckForCast(PT->getPointeeType(), Addr.getPointer(),
|
||||
EmitVTablePtrCheckForCast(PT->getPointeeType(), Addr,
|
||||
/*MayBeNull=*/true,
|
||||
CodeGenFunction::CFITCK_UnrelatedCast,
|
||||
CE->getBeginLoc());
|
||||
|
@ -4756,7 +4756,7 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) {
|
|||
Derived.getPointer(), E->getType());
|
||||
|
||||
if (SanOpts.has(SanitizerKind::CFIDerivedCast))
|
||||
EmitVTablePtrCheckForCast(E->getType(), Derived.getPointer(),
|
||||
EmitVTablePtrCheckForCast(E->getType(), Derived,
|
||||
/*MayBeNull=*/false, CFITCK_DerivedCast,
|
||||
E->getBeginLoc());
|
||||
|
||||
|
@ -4774,7 +4774,7 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) {
|
|||
ConvertTypeForMem(CE->getTypeAsWritten()->getPointeeType()));
|
||||
|
||||
if (SanOpts.has(SanitizerKind::CFIUnrelatedCast))
|
||||
EmitVTablePtrCheckForCast(E->getType(), V.getPointer(),
|
||||
EmitVTablePtrCheckForCast(E->getType(), V,
|
||||
/*MayBeNull=*/false, CFITCK_UnrelatedCast,
|
||||
E->getBeginLoc());
|
||||
|
||||
|
|
|
@ -2039,11 +2039,16 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
|
|||
}
|
||||
|
||||
if (CGF.SanOpts.has(SanitizerKind::CFIUnrelatedCast)) {
|
||||
if (auto PT = DestTy->getAs<PointerType>())
|
||||
CGF.EmitVTablePtrCheckForCast(PT->getPointeeType(), Src,
|
||||
/*MayBeNull=*/true,
|
||||
CodeGenFunction::CFITCK_UnrelatedCast,
|
||||
CE->getBeginLoc());
|
||||
if (auto PT = DestTy->getAs<PointerType>()) {
|
||||
CGF.EmitVTablePtrCheckForCast(
|
||||
PT->getPointeeType(),
|
||||
Address(Src,
|
||||
CGF.ConvertTypeForMem(
|
||||
E->getType()->getAs<PointerType>()->getPointeeType()),
|
||||
CGF.getPointerAlign()),
|
||||
/*MayBeNull=*/true, CodeGenFunction::CFITCK_UnrelatedCast,
|
||||
CE->getBeginLoc());
|
||||
}
|
||||
}
|
||||
|
||||
if (CGF.CGM.getCodeGenOpts().StrictVTablePointers) {
|
||||
|
@ -2198,10 +2203,10 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
|
|||
Derived.getPointer(), DestTy->getPointeeType());
|
||||
|
||||
if (CGF.SanOpts.has(SanitizerKind::CFIDerivedCast))
|
||||
CGF.EmitVTablePtrCheckForCast(
|
||||
DestTy->getPointeeType(), Derived.getPointer(),
|
||||
/*MayBeNull=*/true, CodeGenFunction::CFITCK_DerivedCast,
|
||||
CE->getBeginLoc());
|
||||
CGF.EmitVTablePtrCheckForCast(DestTy->getPointeeType(), Derived,
|
||||
/*MayBeNull=*/true,
|
||||
CodeGenFunction::CFITCK_DerivedCast,
|
||||
CE->getBeginLoc());
|
||||
|
||||
return Derived.getPointer();
|
||||
}
|
||||
|
|
|
@ -2296,9 +2296,8 @@ public:
|
|||
/// Derived is the presumed address of an object of type T after a
|
||||
/// cast. If T is a polymorphic class type, emit a check that the virtual
|
||||
/// table for Derived belongs to a class derived from T.
|
||||
void EmitVTablePtrCheckForCast(QualType T, llvm::Value *Derived,
|
||||
bool MayBeNull, CFITypeCheckKind TCK,
|
||||
SourceLocation Loc);
|
||||
void EmitVTablePtrCheckForCast(QualType T, Address Derived, bool MayBeNull,
|
||||
CFITypeCheckKind TCK, SourceLocation Loc);
|
||||
|
||||
/// EmitVTablePtrCheckForCall - Virtual method MD is being called via VTable.
|
||||
/// If vptr CFI is enabled, emit a check that VTable is valid.
|
||||
|
|
Loading…
Reference in New Issue