diff --git a/clang/lib/AST/ByteCode/EvalEmitter.cpp b/clang/lib/AST/ByteCode/EvalEmitter.cpp index 1ebadae811bdf..2860a09ae6e2d 100644 --- a/clang/lib/AST/ByteCode/EvalEmitter.cpp +++ b/clang/lib/AST/ByteCode/EvalEmitter.cpp @@ -184,7 +184,7 @@ template bool EvalEmitter::emitRet(const SourceInfo &Info) { return true; using T = typename PrimConv::T; - EvalResult.setValue(S.Stk.pop().toAPValue(Ctx.getASTContext())); + EvalResult.takeValue(S.Stk.pop().toAPValue(Ctx.getASTContext())); return true; } @@ -195,7 +195,7 @@ template <> bool EvalEmitter::emitRet(const SourceInfo &Info) { const Pointer &Ptr = S.Stk.pop(); if (Ptr.isFunctionPointer()) { - EvalResult.setValue(Ptr.toAPValue(Ctx.getASTContext())); + EvalResult.takeValue(Ptr.toAPValue(Ctx.getASTContext())); return true; } @@ -224,7 +224,7 @@ template <> bool EvalEmitter::emitRet(const SourceInfo &Info) { if (std::optional V = Ptr.toRValue(Ctx, EvalResult.getSourceType())) { - EvalResult.setValue(*V); + EvalResult.takeValue(std::move(*V)); } else { return false; } @@ -233,14 +233,14 @@ template <> bool EvalEmitter::emitRet(const SourceInfo &Info) { // the result, even if the pointer is dead. // This will later be diagnosed by CheckLValueConstantExpression. if (Ptr.isBlockPointer() && !Ptr.block()->isStatic()) { - EvalResult.setValue(Ptr.toAPValue(Ctx.getASTContext())); + EvalResult.takeValue(Ptr.toAPValue(Ctx.getASTContext())); return true; } if (!Ptr.isLive() && !Ptr.isTemporary()) return false; - EvalResult.setValue(Ptr.toAPValue(Ctx.getASTContext())); + EvalResult.takeValue(Ptr.toAPValue(Ctx.getASTContext())); } return true; @@ -261,7 +261,7 @@ bool EvalEmitter::emitRetValue(const SourceInfo &Info) { if (std::optional APV = Ptr.toRValue(S.getASTContext(), EvalResult.getSourceType())) { - EvalResult.setValue(*APV); + EvalResult.takeValue(std::move(*APV)); return true; } diff --git a/clang/lib/AST/ByteCode/EvaluationResult.h b/clang/lib/AST/ByteCode/EvaluationResult.h index 3b6c65eff1ef8..49a3e5c00eea3 100644 --- a/clang/lib/AST/ByteCode/EvaluationResult.h +++ b/clang/lib/AST/ByteCode/EvaluationResult.h @@ -55,7 +55,7 @@ class EvaluationResult final { void setSource(DeclTy D) { Source = D; } - void setValue(const APValue &V) { + void takeValue(APValue &&V) { // V could still be an LValue. assert(empty()); Value = std::move(V);