E->getType());
}
-bool CodeGenFunction::CanElideObjectPointerNullCheck(const Expr *Obj) {
+bool CodeGenFunction::IsDeclRefOrWrappedCXXThis(const Expr *Obj) {
if (isa<DeclRefExpr>(Obj))
return true;
if (!isa<DeclRefExpr>(E) && !LV.isBitField() && LV.isSimple()) {
SanitizerSet SkippedChecks;
if (const auto *ME = dyn_cast<MemberExpr>(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);
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);
SanitizerSet SkippedChecks;
if (const auto *CMCE = dyn_cast<CXXMemberCallExpr>(CE))
- if (CanElideObjectPointerNullCheck(CMCE->getImplicitObjectArgument()))
+ if (IsDeclRefOrWrappedCXXThis(CMCE->getImplicitObjectArgument()))
SkippedChecks.set(SanitizerKind::Null, true);
EmitTypeCheck(
isa<CXXConstructorDecl>(CalleeDecl) ? CodeGenFunction::TCK_ConstructorCall
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