summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp6
-rw-r--r--clang/lib/CodeGen/CGExprCXX.cpp2
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h5
3 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 276716ffb76..4e3bbb69c57 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/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<DeclRefExpr>(Obj))
return true;
@@ -987,7 +987,7 @@ LValue CodeGenFunction::EmitCheckedLValue(const Expr *E, TypeCheckKind TCK) {
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);
@@ -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/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index 3751ef116a8..29c307bbef8 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -292,7 +292,7 @@ RValue CodeGenFunction::EmitCXXMemberOrOperatorMemberCallExpr(
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
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 80a9a0e5b11..99ab1a19361 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/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
OpenPOWER on IntegriCloud