[cfe-commits] r133521 - in /cfe/trunk: include/clang/AST/ include/clang/Basic/ include/clang/Serialization/ lib/AST/ lib/Analysis/ lib/CodeGen/ lib/Sema/ lib/Serialization/ lib/StaticAnalyzer/Checkers/ lib/StaticAnalyzer/Core/ test/CodeGenCXX/ tools/libclang/

John McCall rjmccall at apple.com
Tue Jun 21 10:27:52 PDT 2011


On Jun 21, 2011, at 10:03 AM, Douglas Gregor wrote:
> +  /// \brief Determine whether this materialized temporary is bound to an
> +  /// lvalue reference; otherwise, it's bound to an rvalue reference.
> +  bool BoundToLvalueReference() const { 
> +    return getValueKind() == VK_LValue;
> +  }
> +  

Maybe isBoundToLvalueReference, or at least IsBoundToLvalueReference?

> Modified: cfe/trunk/lib/AST/Decl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=133521&r1=133520&r2=133521&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/Decl.cpp (original)
> +++ cfe/trunk/lib/AST/Decl.cpp Tue Jun 21 12:03:29 2011
> @@ -1312,6 +1312,20 @@
>   Init = I;
> }
> 
> +bool VarDecl::extendsLifetimeOfTemporary() const {
> +  if (!getType()->isReferenceType())
> +    return false;

Could this be an assert?  Is there any good reason to support calling
this method on variables not known to have reference type?

> Modified: cfe/trunk/lib/AST/Expr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=133521&r1=133520&r2=133521&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/Expr.cpp (original)
> +++ cfe/trunk/lib/AST/Expr.cpp Tue Jun 21 12:03:29 2011
> @@ -1568,6 +1573,10 @@
>     return (cast<ImplicitCastExpr>(this)
>             ->getSubExpr()->isUnusedResultAWarning(Loc, R1, R2, Ctx));
> 
> +  case MaterializeTemporaryExprClass:
> +    return cast<MaterializeTemporaryExpr>(this)->GetTemporaryExpr()
> +                                    ->isUnusedResultAWarning(Loc, R1, R2, Ctx);
> +      

Can this really ever happen?

> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=133521&r1=133520&r2=133521&view=diff
> ==============================================================================
> @@ -2067,11 +2074,20 @@
>   return getOpaqueLValueMapping(e);
> }
> 
> +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());
> +}

Use CGF::MakeAddrLValue, please.

John.



More information about the cfe-commits mailing list