@@ -184,7 +184,7 @@ template <PrimType OpType> bool EvalEmitter::emitRet(const SourceInfo &Info) {
184184 return true ;
185185
186186 using T = typename PrimConv<OpType>::T;
187- EvalResult.setValue (S.Stk .pop <T>().toAPValue (Ctx.getASTContext ()));
187+ EvalResult.takeValue (S.Stk .pop <T>().toAPValue (Ctx.getASTContext ()));
188188 return true ;
189189}
190190
@@ -195,7 +195,7 @@ template <> bool EvalEmitter::emitRet<PT_Ptr>(const SourceInfo &Info) {
195195 const Pointer &Ptr = S.Stk .pop <Pointer>();
196196
197197 if (Ptr.isFunctionPointer ()) {
198- EvalResult.setValue (Ptr.toAPValue (Ctx.getASTContext ()));
198+ EvalResult.takeValue (Ptr.toAPValue (Ctx.getASTContext ()));
199199 return true ;
200200 }
201201
@@ -224,7 +224,7 @@ template <> bool EvalEmitter::emitRet<PT_Ptr>(const SourceInfo &Info) {
224224
225225 if (std::optional<APValue> V =
226226 Ptr.toRValue (Ctx, EvalResult.getSourceType ())) {
227- EvalResult.setValue (*V );
227+ EvalResult.takeValue ( std::move (*V) );
228228 } else {
229229 return false ;
230230 }
@@ -233,14 +233,14 @@ template <> bool EvalEmitter::emitRet<PT_Ptr>(const SourceInfo &Info) {
233233 // the result, even if the pointer is dead.
234234 // This will later be diagnosed by CheckLValueConstantExpression.
235235 if (Ptr.isBlockPointer () && !Ptr.block ()->isStatic ()) {
236- EvalResult.setValue (Ptr.toAPValue (Ctx.getASTContext ()));
236+ EvalResult.takeValue (Ptr.toAPValue (Ctx.getASTContext ()));
237237 return true ;
238238 }
239239
240240 if (!Ptr.isLive () && !Ptr.isTemporary ())
241241 return false ;
242242
243- EvalResult.setValue (Ptr.toAPValue (Ctx.getASTContext ()));
243+ EvalResult.takeValue (Ptr.toAPValue (Ctx.getASTContext ()));
244244 }
245245
246246 return true ;
@@ -261,7 +261,7 @@ bool EvalEmitter::emitRetValue(const SourceInfo &Info) {
261261
262262 if (std::optional<APValue> APV =
263263 Ptr.toRValue (S.getASTContext (), EvalResult.getSourceType ())) {
264- EvalResult.setValue ( *APV);
264+ EvalResult.takeValue ( std::move ( *APV) );
265265 return true ;
266266 }
267267
0 commit comments