Skip to content
Snippets Groups Projects
Commit b7b8b123 authored by David Majnemer's avatar David Majnemer
Browse files

Address Richard's comments

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213403 91177308-0d34-0410-b5e6-96231b3b80d8
parent 595a3147
No related branches found
No related tags found
No related merge requests found
...@@ -1616,14 +1616,13 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) { ...@@ -1616,14 +1616,13 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) {
} }
static bool isGLValueFromPointerDeref(const Expr *E) { static bool isGLValueFromPointerDeref(const Expr *E) {
E = E->IgnoreParenCasts(); E = E->IgnoreParens();
if (isa<ArraySubscriptExpr>(E)) if (const auto *CE = dyn_cast<CastExpr>(E)) {
return true; if (!CE->getSubExpr()->isGLValue())
return false;
if (const auto *UO = dyn_cast<UnaryOperator>(E)) return isGLValueFromPointerDeref(CE->getSubExpr());
if (UO->getOpcode() == UO_Deref) }
return true;
if (const auto *BO = dyn_cast<BinaryOperator>(E)) if (const auto *BO = dyn_cast<BinaryOperator>(E))
if (BO->getOpcode() == BO_Comma) if (BO->getOpcode() == BO_Comma)
...@@ -1638,6 +1637,15 @@ static bool isGLValueFromPointerDeref(const Expr *E) { ...@@ -1638,6 +1637,15 @@ static bool isGLValueFromPointerDeref(const Expr *E) {
return isGLValueFromPointerDeref(OVE->getSourceExpr()) || return isGLValueFromPointerDeref(OVE->getSourceExpr()) ||
isGLValueFromPointerDeref(BCO->getFalseExpr()); isGLValueFromPointerDeref(BCO->getFalseExpr());
// C++11 [expr.sub]p1:
// The expression E1[E2] is identical (by definition) to *((E1)+(E2))
if (isa<ArraySubscriptExpr>(E))
return true;
if (const auto *UO = dyn_cast<UnaryOperator>(E))
if (UO->getOpcode() == UO_Deref)
return true;
return false; return false;
} }
......
...@@ -52,3 +52,7 @@ void f9(A *x) { typeid(0[x]); } ...@@ -52,3 +52,7 @@ void f9(A *x) { typeid(0[x]); }
// CHECK-LABEL: define void @_Z2f9P1A // CHECK-LABEL: define void @_Z2f9P1A
// CHECK: icmp eq {{.*}}, null // CHECK: icmp eq {{.*}}, null
// CHECK-NEXT: br i1 // CHECK-NEXT: br i1
void f10(A *x) { typeid((const A &)(A)*x); }
// CHECK-LABEL: define void @_Z3f10P1A
// CHECK-NOT: icmp eq {{.*}}, null
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment