Look through parentheses when deciding whether an expr is a temporary object. Fixes PR8683.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120247 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 3e3792e..3a112a7 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -1804,7 +1804,7 @@
/// \brief Skip over any no-op casts and any temporary-binding
/// expressions.
-static const Expr *skipTemporaryBindingsAndNoOpCasts(const Expr *E) {
+static const Expr *skipTemporaryBindingsNoOpCastsAndParens(const Expr *E) {
while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) {
if (ICE->getCastKind() == CK_NoOp)
E = ICE->getSubExpr();
@@ -1821,8 +1821,8 @@
else
break;
}
-
- return E;
+
+ return E->IgnoreParens();
}
/// isTemporaryObject - Determines if this expression produces a
@@ -1831,7 +1831,7 @@
if (!C.hasSameUnqualifiedType(getType(), C.getTypeDeclType(TempTy)))
return false;
- const Expr *E = skipTemporaryBindingsAndNoOpCasts(this);
+ const Expr *E = skipTemporaryBindingsNoOpCastsAndParens(this);
// Temporaries are by definition pr-values of class type.
if (!E->Classify(C).isPRValue()) {