From: John McCall Date: Wed, 6 Jan 2016 23:34:20 +0000 (+0000) Subject: Properly bind up any cleanups in an ExprWithCleanups after X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2b71f2cb4db520bc83b10e621d17142ed96d1540;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@256996 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index f1b9987a2f..8e50d5a103 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -4313,17 +4313,16 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc, if (Result.isInvalid()) return ExprError(); - Expr *Arg = Result.getAs(); - CheckCompletedExpr(Arg, Param->getOuterLocStart()); + Result = ActOnFinishFullExpr(Result.getAs(), + Param->getOuterLocStart()); + if (Result.isInvalid()) + return ExprError(); // Remember the instantiated default argument. - Param->setDefaultArg(Arg); + Param->setDefaultArg(Result.getAs()); 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