summaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Interp.h
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/AST/ByteCode/Interp.h')
-rw-r--r--clang/lib/AST/ByteCode/Interp.h27
1 files changed, 9 insertions, 18 deletions
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 2da220237803..9a7bd03bea07 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -1527,15 +1527,12 @@ bool InitGlobal(InterpState &S, CodePtr OpPC, uint32_t I) {
template <PrimType Name, class T = typename PrimConv<Name>::T>
bool InitGlobalTemp(InterpState &S, CodePtr OpPC, uint32_t I,
const LifetimeExtendedTemporaryDecl *Temp) {
- const Pointer &Ptr = S.P.getGlobal(I);
-
- const T Value = S.Stk.peek<T>();
- APValue APV = Value.toAPValue(S.getASTContext());
- APValue *Cached = Temp->getOrCreateValue(true);
- *Cached = APV;
+ if (S.EvalMode == EvaluationMode::ConstantFold)
+ return false;
+ assert(Temp);
+ const Pointer &Ptr = S.P.getGlobal(I);
assert(Ptr.getDeclDesc()->asExpr());
-
S.SeenGlobalTemporaries.push_back(
std::make_pair(Ptr.getDeclDesc()->asExpr(), Temp));
@@ -1549,20 +1546,14 @@ bool InitGlobalTemp(InterpState &S, CodePtr OpPC, uint32_t I,
/// 3) Initialized global with index \I with that
inline bool InitGlobalTempComp(InterpState &S, CodePtr OpPC,
const LifetimeExtendedTemporaryDecl *Temp) {
+ if (S.EvalMode == EvaluationMode::ConstantFold)
+ return false;
assert(Temp);
- const Pointer &P = S.Stk.peek<Pointer>();
- APValue *Cached = Temp->getOrCreateValue(true);
+ const Pointer &Ptr = S.Stk.peek<Pointer>();
S.SeenGlobalTemporaries.push_back(
- std::make_pair(P.getDeclDesc()->asExpr(), Temp));
-
- if (std::optional<APValue> APV =
- P.toRValue(S.getASTContext(), Temp->getTemporaryExpr()->getType())) {
- *Cached = *APV;
- return true;
- }
-
- return false;
+ std::make_pair(Ptr.getDeclDesc()->asExpr(), Temp));
+ return true;
}
template <PrimType Name, class T = typename PrimConv<Name>::T>