From 0da82610a9eb9b5b8d4b9e2fcef99b5996355545 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Thu, 23 Feb 2017 01:22:38 +0000 Subject: [PATCH] Rename a helper function, NFC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@295918 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExpr.cpp | 6 +++--- lib/CodeGen/CGExprCXX.cpp | 2 +- lib/CodeGen/CodeGenFunction.h | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 276716ffb7..4e3bbb69c5 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -952,7 +952,7 @@ LValue CodeGenFunction::EmitUnsupportedLValue(const Expr *E, E->getType()); } -bool CodeGenFunction::CanElideObjectPointerNullCheck(const Expr *Obj) { +bool CodeGenFunction::IsDeclRefOrWrappedCXXThis(const Expr *Obj) { if (isa(Obj)) return true; @@ -987,7 +987,7 @@ LValue CodeGenFunction::EmitCheckedLValue(const Expr *E, TypeCheckKind TCK) { if (!isa(E) && !LV.isBitField() && LV.isSimple()) { SanitizerSet SkippedChecks; if (const auto *ME = dyn_cast(E)) - if (CanElideObjectPointerNullCheck(ME->getBase())) + if (IsDeclRefOrWrappedCXXThis(ME->getBase())) SkippedChecks.set(SanitizerKind::Null, true); EmitTypeCheck(TCK, E->getExprLoc(), LV.getPointer(), E->getType(), LV.getAlignment(), SkippedChecks); @@ -3372,7 +3372,7 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) { Address Addr = EmitPointerWithAlignment(BaseExpr, &AlignSource); QualType PtrTy = BaseExpr->getType()->getPointeeType(); SanitizerSet SkippedChecks; - if (CanElideObjectPointerNullCheck(BaseExpr)) + if (IsDeclRefOrWrappedCXXThis(BaseExpr)) SkippedChecks.set(SanitizerKind::Null, true); EmitTypeCheck(TCK_MemberAccess, E->getExprLoc(), Addr.getPointer(), PtrTy, /*Alignment=*/CharUnits::Zero(), SkippedChecks); diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index 3751ef116a..29c307bbef 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -292,7 +292,7 @@ RValue CodeGenFunction::EmitCXXMemberOrOperatorMemberCallExpr( SanitizerSet SkippedChecks; if (const auto *CMCE = dyn_cast(CE)) - if (CanElideObjectPointerNullCheck(CMCE->getImplicitObjectArgument())) + if (IsDeclRefOrWrappedCXXThis(CMCE->getImplicitObjectArgument())) SkippedChecks.set(SanitizerKind::Null, true); EmitTypeCheck( isa(CalleeDecl) ? CodeGenFunction::TCK_ConstructorCall diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 80a9a0e5b1..99ab1a1936 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -2030,8 +2030,9 @@ public: llvm::BlockAddress *GetAddrOfLabel(const LabelDecl *L); llvm::BasicBlock *GetIndirectGotoBlock(); - /// Check if the null check for \p ObjectPointer can be skipped. - static bool CanElideObjectPointerNullCheck(const Expr *ObjectPointer); + /// Check if \p E is a reference, or a C++ "this" pointer wrapped in value- + /// preserving casts. + static bool IsDeclRefOrWrappedCXXThis(const Expr *E); /// EmitNullInitialization - Generate code to set a value of the given type to /// null, If the type contains data member pointers, they will be initialized -- 2.40.0