diff options
Diffstat (limited to 'clang/lib/AST/ByteCode')
-rw-r--r-- | clang/lib/AST/ByteCode/Compiler.cpp | 5 | ||||
-rw-r--r-- | clang/lib/AST/ByteCode/Interp.h | 9 | ||||
-rw-r--r-- | clang/lib/AST/ByteCode/InterpState.h | 2 | ||||
-rw-r--r-- | clang/lib/AST/ByteCode/Opcodes.td | 3 |
4 files changed, 18 insertions, 1 deletions
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp index 157e306..d3eabc5 100644 --- a/clang/lib/AST/ByteCode/Compiler.cpp +++ b/clang/lib/AST/ByteCode/Compiler.cpp @@ -6466,8 +6466,13 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) { // In case we need to re-visit a declaration. auto revisit = [&](const VarDecl *VD) -> bool { + if (!this->emitPushCC(VD->hasConstantInitialization(), E)) + return false; auto VarState = this->visitDecl(VD, /*IsConstexprUnknown=*/true); + if (!this->emitPopCC(E)) + return false; + if (VarState.notCreated()) return true; if (!VarState) diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h index bd58c2a..49e2326 100644 --- a/clang/lib/AST/ByteCode/Interp.h +++ b/clang/lib/AST/ByteCode/Interp.h @@ -2848,6 +2848,15 @@ inline bool EndSpeculation(InterpState &S, CodePtr OpPC) { return true; } +inline bool PushCC(InterpState &S, CodePtr OpPC, bool Value) { + S.ConstantContextOverride = Value; + return true; +} +inline bool PopCC(InterpState &S, CodePtr OpPC) { + S.ConstantContextOverride = std::nullopt; + return true; +} + /// Do nothing and just abort execution. inline bool Error(InterpState &S, CodePtr OpPC) { return false; } diff --git a/clang/lib/AST/ByteCode/InterpState.h b/clang/lib/AST/ByteCode/InterpState.h index 74001b8..528c1a2 100644 --- a/clang/lib/AST/ByteCode/InterpState.h +++ b/clang/lib/AST/ByteCode/InterpState.h @@ -127,7 +127,6 @@ private: SourceMapper *M; /// Allocator used for dynamic allocations performed via the program. DynamicAllocator Alloc; - std::optional<bool> ConstantContextOverride; public: /// Reference to the module containing all bytecode. @@ -147,6 +146,7 @@ public: /// Things needed to do speculative execution. SmallVectorImpl<PartialDiagnosticAt> *PrevDiags = nullptr; unsigned SpeculationDepth = 0; + std::optional<bool> ConstantContextOverride; llvm::SmallVector< std::pair<const Expr *, const LifetimeExtendedTemporaryDecl *>> diff --git a/clang/lib/AST/ByteCode/Opcodes.td b/clang/lib/AST/ByteCode/Opcodes.td index 5a9079f..8451e54 100644 --- a/clang/lib/AST/ByteCode/Opcodes.td +++ b/clang/lib/AST/ByteCode/Opcodes.td @@ -872,3 +872,6 @@ def GetTypeidPtr : Opcode { let Args = [ArgTypePtr]; } def DiagTypeid : Opcode; def CheckDestruction : Opcode; + +def PushCC : Opcode { let Args = [ArgBool]; } +def PopCC : Opcode; |