]> granicus.if.org Git - clang/commitdiff
A few tweaks to MaterializeTemporaryExpr suggested by John.
authorDouglas Gregor <dgregor@apple.com>
Tue, 21 Jun 2011 18:20:46 +0000 (18:20 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 21 Jun 2011 18:20:46 +0000 (18:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133528 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/ExprCXX.h
lib/AST/Decl.cpp
lib/AST/Expr.cpp
lib/AST/ExprClassification.cpp
lib/CodeGen/CGExpr.cpp

index 1b1019e5546d40eb5e0597812805236a1b2bdefc..aec2c6a8bfd4588490ee218d46fcf5de575d7db3 100644 (file)
@@ -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;
   }
   
index cdec049cb12ac660995cd2feb13a94505ff19170..7ca936abc91b20abbd7af6a3ceda5b4958eb84fe 100644 (file)
@@ -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)
index 1faceb9425811646c7b101d5d98bfa9e5966b1d3..2adaba11a0da8e3573f3dfa63f7231865c4fab7f 100644 (file)
@@ -1573,10 +1573,6 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1,
     return (cast<ImplicitCastExpr>(this)
             ->getSubExpr()->isUnusedResultAWarning(Loc, R1, R2, Ctx));
 
-  case MaterializeTemporaryExprClass:
-    return cast<MaterializeTemporaryExpr>(this)->GetTemporaryExpr()
-                                    ->isUnusedResultAWarning(Loc, R1, R2, Ctx);
-      
   case CXXDefaultArgExprClass:
     return (cast<CXXDefaultArgExpr>(this)
             ->getExpr()->isUnusedResultAWarning(Loc, R1, R2, Ctx));
index 2d824ce8fd77b25035893f495513d24ea74bd33c..2a05c1fccff1398caeb6a9cfd940f7bd3ed0d16d 100644 (file)
@@ -343,7 +343,7 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) {
     return ClassifyInternal(Ctx, cast<PackExpansionExpr>(E)->getPattern());
       
   case Expr::MaterializeTemporaryExprClass:
-    return cast<MaterializeTemporaryExpr>(E)->BoundToLvalueReference()
+    return cast<MaterializeTemporaryExpr>(E)->isBoundToLvalueReference()
               ? Cl::CL_LValue 
               : Cl::CL_XValue;
   }
index d5c18eba70ae2ee731275e1d34fbf32de2f15bbe..2c00b9bf06a120021376ae22134dc968ebc11870 100644 (file)
@@ -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());
 }