From: Arthur Eubanks Date: Wed, 23 Feb 2022 21:26:32 +0000 (-0800) Subject: [clang] Remove Address::deprecated() from CGClass.cpp X-Git-Tag: upstream/15.0.7~15488 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4cb24ef90a691489f22a36976a1b33acd65901fa;p=platform%2Fupstream%2Fllvm.git [clang] Remove Address::deprecated() from CGClass.cpp --- diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index 9a175d1..4a49fc4 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -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); diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 37f9a79..8f1e608 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -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()) - 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()); diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index d3db63f..93fb7d3 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -2039,11 +2039,16 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) { } if (CGF.SanOpts.has(SanitizerKind::CFIUnrelatedCast)) { - if (auto PT = DestTy->getAs()) - CGF.EmitVTablePtrCheckForCast(PT->getPointeeType(), Src, - /*MayBeNull=*/true, - CodeGenFunction::CFITCK_UnrelatedCast, - CE->getBeginLoc()); + if (auto PT = DestTy->getAs()) { + CGF.EmitVTablePtrCheckForCast( + PT->getPointeeType(), + Address(Src, + CGF.ConvertTypeForMem( + E->getType()->getAs()->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(); } diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index f9932e4..5c8aef4 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -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.