From: Douglas Gregor Date: Tue, 21 Jun 2011 18:20:46 +0000 (+0000) Subject: A few tweaks to MaterializeTemporaryExpr suggested by John. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0b5810882bd34183c2b764676cafa4c2ce324740;p=clang A few tweaks to MaterializeTemporaryExpr suggested by John. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133528 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 1b1019e554..aec2c6a8bf 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -3029,7 +3029,7 @@ public: /// \brief Determine whether this materialized temporary is bound to an /// lvalue reference; otherwise, it's bound to an rvalue reference. - bool BoundToLvalueReference() const { + bool isBoundToLvalueReference() const { return getValueKind() == VK_LValue; } diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index cdec049cb1..7ca936abc9 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -1313,8 +1313,7 @@ void VarDecl::setInit(Expr *I) { } bool VarDecl::extendsLifetimeOfTemporary() const { - if (!getType()->isReferenceType()) - return false; + assert(getType()->isReferenceType() &&"Non-references never extend lifetime"); const Expr *E = getInit(); if (!E) diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 1faceb9425..2adaba11a0 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1573,10 +1573,6 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1, return (cast(this) ->getSubExpr()->isUnusedResultAWarning(Loc, R1, R2, Ctx)); - case MaterializeTemporaryExprClass: - return cast(this)->GetTemporaryExpr() - ->isUnusedResultAWarning(Loc, R1, R2, Ctx); - case CXXDefaultArgExprClass: return (cast(this) ->getExpr()->isUnusedResultAWarning(Loc, R1, R2, Ctx)); diff --git a/lib/AST/ExprClassification.cpp b/lib/AST/ExprClassification.cpp index 2d824ce8fd..2a05c1fccf 100644 --- a/lib/AST/ExprClassification.cpp +++ b/lib/AST/ExprClassification.cpp @@ -343,7 +343,7 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) { return ClassifyInternal(Ctx, cast(E)->getPattern()); case Expr::MaterializeTemporaryExprClass: - return cast(E)->BoundToLvalueReference() + return cast(E)->isBoundToLvalueReference() ? Cl::CL_LValue : Cl::CL_XValue; } diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index d5c18eba70..2c00b9bf06 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -2078,9 +2078,7 @@ LValue CodeGenFunction::EmitMaterializeTemporaryExpr( const MaterializeTemporaryExpr *E) { RValue RV = EmitReferenceBindingToExpr(E->GetTemporaryExpr(), /*InitializedDecl=*/0); - return LValue::MakeAddr(RV.getScalarVal(), E->getType(), - CGM.getContext().getTypeAlign(E->getType()), - CGM.getContext()); + return MakeAddrLValue(RV.getScalarVal(), E->getType()); }