r256996 - Properly bind up any cleanups in an ExprWithCleanups after

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 6 15:54:44 PST 2016


On Wed, Jan 6, 2016 at 3:34 PM, John McCall via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: rjmccall
> Date: Wed Jan  6 17:34:20 2016
> New Revision: 256996
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256996&view=rev
> Log:
> Properly bind up any cleanups in an ExprWithCleanups after
> instantiating a default argument expression.
>
> This was previously just working implicitly by reinstantiating
> in the current context, but caching means that we weren't
> registering cleanups in subsequent uses.
>

Isn't the code you changed below only reached the first time anyway, now
that we only instantiate the default argument once?


> Modified:
>     cfe/trunk/lib/Sema/SemaExpr.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=256996&r1=256995&r2=256996&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Jan  6 17:34:20 2016
> @@ -4313,17 +4313,16 @@ ExprResult Sema::BuildCXXDefaultArgExpr(
>      if (Result.isInvalid())
>        return ExprError();
>
> -    Expr *Arg = Result.getAs<Expr>();
> -    CheckCompletedExpr(Arg, Param->getOuterLocStart());
> +    Result = ActOnFinishFullExpr(Result.getAs<Expr>(),
> +                                 Param->getOuterLocStart());
> +    if (Result.isInvalid())
> +      return ExprError();
>
>      // Remember the instantiated default argument.
> -    Param->setDefaultArg(Arg);
> +    Param->setDefaultArg(Result.getAs<Expr>());
>      if (ASTMutationListener *L = getASTMutationListener()) {
>        L->DefaultArgumentInstantiated(Param);
>      }
> -
> -    // Build the default argument expression.
> -    return CXXDefaultArgExpr::Create(Context, CallLoc, Param);
>    }
>
>    // If the default expression creates temporaries, we need to
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160106/c901c99e/attachment.html>


More information about the cfe-commits mailing list