]> granicus.if.org Git - clang/commitdiff
Properly bind up any cleanups in an ExprWithCleanups after
authorJohn McCall <rjmccall@apple.com>
Wed, 6 Jan 2016 23:34:20 +0000 (23:34 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 6 Jan 2016 23:34:20 +0000 (23:34 +0000)
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

lib/Sema/SemaExpr.cpp

index f1b9987a2f0437f47a21c41a02a18bc28f4fb166..8e50d5a103ccf988269ccc5c2b0d536bbf42d3b8 100644 (file)
@@ -4313,17 +4313,16 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc,
     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