clang 23.0.0git
Compiler.h
Go to the documentation of this file.
1//===--- Compiler.h - Code generator for expressions -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Defines the constexpr bytecode compiler.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_AST_INTERP_BYTECODEEXPRGEN_H
14#define LLVM_CLANG_AST_INTERP_BYTECODEEXPRGEN_H
15
16#include "ByteCodeEmitter.h"
17#include "EvalEmitter.h"
18#include "Pointer.h"
19#include "PrimType.h"
20#include "Record.h"
21#include "clang/AST/Decl.h"
22#include "clang/AST/Expr.h"
24
25namespace clang {
26class QualType;
27
28namespace interp {
29
30template <class Emitter> class LocalScope;
31template <class Emitter> class DestructorScope;
32template <class Emitter> class VariableScope;
33template <class Emitter> class DeclScope;
34template <class Emitter> class InitLinkScope;
35template <class Emitter> class InitStackScope;
36template <class Emitter> class OptionScope;
37template <class Emitter> class ArrayIndexScope;
38template <class Emitter> class SourceLocScope;
39template <class Emitter> class LoopScope;
40template <class Emitter> class LabelScope;
41template <class Emitter> class SwitchScope;
42template <class Emitter> class StmtExprScope;
43template <class Emitter> class LocOverrideScope;
44
45template <class Emitter> class Compiler;
46struct InitLink {
47public:
48 enum {
49 K_This = 0,
51 K_Temp = 2,
52 K_Decl = 3,
53 K_Elem = 5,
54 K_RVO = 6,
56 K_DIE = 8,
57 };
58
59 static InitLink This() { return InitLink{K_This}; }
60 static InitLink InitList() { return InitLink{K_InitList}; }
61 static InitLink RVO() { return InitLink{K_RVO}; }
62 static InitLink DIE() { return InitLink{K_DIE}; }
63 static InitLink Field(unsigned Offset) {
64 InitLink IL{K_Field};
65 IL.Offset = Offset;
66 return IL;
67 }
68 static InitLink Temp(unsigned Offset) {
69 InitLink IL{K_Temp};
70 IL.Offset = Offset;
71 return IL;
72 }
73 static InitLink Decl(const ValueDecl *D) {
74 InitLink IL{K_Decl};
75 IL.D = D;
76 return IL;
77 }
78 static InitLink Elem(unsigned Index) {
79 InitLink IL{K_Elem};
80 IL.Offset = Index;
81 return IL;
82 }
83
84 InitLink(uint8_t Kind) : Kind(Kind) {}
85 template <class Emitter>
86 bool emit(Compiler<Emitter> *Ctx, const Expr *E) const;
87
88 uint32_t Kind;
89 union {
90 unsigned Offset;
91 const ValueDecl *D;
92 };
93};
94
95/// State encapsulating if a the variable creation has been successful,
96/// unsuccessful, or no variable has been created at all.
98 std::optional<bool> S = std::nullopt;
99 VarCreationState() = default;
100 VarCreationState(bool b) : S(b) {}
102
103 operator bool() const { return S && *S; }
104 bool notCreated() const { return !S; }
105};
106
108
109/// Compilation context for expressions.
110template <class Emitter>
111class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
112 public Emitter {
113protected:
114 // Aliases for types defined in the emitter.
115 using LabelTy = typename Emitter::LabelTy;
116 using AddrTy = typename Emitter::AddrTy;
118 using CaseMap = llvm::DenseMap<const SwitchCase *, LabelTy>;
119
133
134 /// Current compilation context.
136 /// Program to link to.
138
139public:
140 /// Initializes the compiler and the backend emitter.
141 template <typename... Tys>
142 Compiler(Context &Ctx, Program &P, Tys &&...Args)
143 : Emitter(Ctx, P, Args...), Ctx(Ctx), P(P) {}
144
145 // Expressions.
146 bool VisitCastExpr(const CastExpr *E);
148 bool VisitIntegerLiteral(const IntegerLiteral *E);
152 bool VisitParenExpr(const ParenExpr *E);
153 bool VisitBinaryOperator(const BinaryOperator *E);
154 bool VisitLogicalBinOp(const BinaryOperator *E);
156 bool VisitComplexBinOp(const BinaryOperator *E);
157 bool VisitVectorBinOp(const BinaryOperator *E);
161 bool VisitCallExpr(const CallExpr *E);
162 bool VisitBuiltinCallExpr(const CallExpr *E, unsigned BuiltinID);
166 bool VisitGNUNullExpr(const GNUNullExpr *E);
167 bool VisitCXXThisExpr(const CXXThisExpr *E);
168 bool VisitUnaryOperator(const UnaryOperator *E);
171 bool VisitDeclRefExpr(const DeclRefExpr *E);
175 bool VisitInitListExpr(const InitListExpr *E);
177 bool VisitConstantExpr(const ConstantExpr *E);
179 bool VisitMemberExpr(const MemberExpr *E);
184 bool VisitStringLiteral(const StringLiteral *E);
186 bool VisitObjCEncodeExpr(const ObjCEncodeExpr *E);
196 bool VisitTypeTraitExpr(const TypeTraitExpr *E);
198 bool VisitLambdaExpr(const LambdaExpr *E);
199 bool VisitPredefinedExpr(const PredefinedExpr *E);
200 bool VisitCXXThrowExpr(const CXXThrowExpr *E);
205 bool VisitSourceLocExpr(const SourceLocExpr *E);
206 bool VisitOffsetOfExpr(const OffsetOfExpr *E);
208 bool VisitSizeOfPackExpr(const SizeOfPackExpr *E);
210 bool VisitChooseExpr(const ChooseExpr *E);
211 bool VisitEmbedExpr(const EmbedExpr *E);
215 bool VisitCXXUuidofExpr(const CXXUuidofExpr *E);
216 bool VisitRequiresExpr(const RequiresExpr *E);
221 bool VisitRecoveryExpr(const RecoveryExpr *E);
222 bool VisitAddrLabelExpr(const AddrLabelExpr *E);
226 bool VisitObjCBoxedExpr(const ObjCBoxedExpr *E);
228 bool VisitStmtExpr(const StmtExpr *E);
229 bool VisitCXXNewExpr(const CXXNewExpr *E);
230 bool VisitCXXDeleteExpr(const CXXDeleteExpr *E);
231 bool VisitBlockExpr(const BlockExpr *E);
232 bool VisitCXXTypeidExpr(const CXXTypeidExpr *E);
236
237 // Statements.
238 bool visitCompoundStmt(const CompoundStmt *S);
239 bool visitDeclStmt(const DeclStmt *DS, bool EvaluateConditionDecl = false);
240 bool visitReturnStmt(const ReturnStmt *RS);
241 bool visitIfStmt(const IfStmt *IS);
242 bool visitWhileStmt(const WhileStmt *S);
243 bool visitDoStmt(const DoStmt *S);
244 bool visitForStmt(const ForStmt *S);
246 bool visitBreakStmt(const BreakStmt *S);
247 bool visitContinueStmt(const ContinueStmt *S);
248 bool visitSwitchStmt(const SwitchStmt *S);
249 bool visitCaseStmt(const CaseStmt *S);
250 bool visitDefaultStmt(const DefaultStmt *S);
251 bool visitAttributedStmt(const AttributedStmt *S);
252 bool visitCXXTryStmt(const CXXTryStmt *S);
253
254protected:
255 bool visitStmt(const Stmt *S);
256 bool visitExpr(const Expr *E, bool DestroyToplevelScope) override;
257 bool visitLValueExpr(const Expr *E, bool DestroyToplevelScope) override;
258 bool visitFunc(const FunctionDecl *F) override;
259
260 bool visitDeclAndReturn(const VarDecl *VD, const Expr *Init,
261 bool ConstantContext) override;
262 bool visitDtorCall(const VarDecl *VD, const APValue &Value) override;
263
264protected:
265 /// Emits scope cleanup instructions.
266 bool emitCleanup();
267
268 /// Returns a record type from a record or pointer type.
269 const RecordType *getRecordTy(QualType Ty);
270
271 /// Returns a record from a record or pointer type.
273 Record *getRecord(const RecordDecl *RD);
274
275 /// Returns a function for the given FunctionDecl.
276 /// If the function does not exist yet, it is compiled.
277 const Function *getFunction(const FunctionDecl *FD);
278
279 OptPrimType classify(const Expr *E) const { return Ctx.classify(E); }
280 OptPrimType classify(QualType Ty) const { return Ctx.classify(Ty); }
281 bool canClassify(const Expr *E) const { return Ctx.canClassify(E); }
282 bool canClassify(QualType T) const { return Ctx.canClassify(T); }
283
284 /// Classifies a known primitive type.
286 if (auto T = classify(Ty)) {
287 return *T;
288 }
289 llvm_unreachable("not a primitive type");
290 }
291 /// Classifies a known primitive expression.
292 PrimType classifyPrim(const Expr *E) const {
293 if (auto T = classify(E))
294 return *T;
295 llvm_unreachable("not a primitive type");
296 }
297
298 /// Evaluates an expression and places the result on the stack. If the
299 /// expression is of composite type, a local variable will be created
300 /// and a pointer to said variable will be placed on the stack.
301 bool visit(const Expr *E) override;
302 /// Compiles an initializer. This is like visit() but it will never
303 /// create a variable and instead rely on a variable already having
304 /// been created. visitInitializer() then relies on a pointer to this
305 /// variable being on top of the stack.
306 bool visitInitializer(const Expr *E);
307 /// Similar, but will also pop the pointer.
308 bool visitInitializerPop(const Expr *E);
309 bool visitAsLValue(const Expr *E);
310 /// Evaluates an expression for side effects and discards the result.
311 bool discard(const Expr *E);
312 /// Just pass evaluation on to \p E. This leaves all the parsing flags
313 /// intact.
314 bool delegate(const Expr *E);
315 /// Creates and initializes a variable from the given decl.
317 bool Toplevel = false);
319 /// Visit an APValue.
320 bool visitAPValue(const APValue &Val, PrimType ValType, const Expr *E);
321 bool visitAPValueInitializer(const APValue &Val, const Expr *E, QualType T);
322 /// Visit the given decl as if we have a reference to it.
323 bool visitDeclRef(const ValueDecl *D, const Expr *E);
324
325 /// Visits an expression and converts it to a boolean.
326 bool visitBool(const Expr *E);
327
328 bool visitInitList(ArrayRef<const Expr *> Inits, const Expr *ArrayFiller,
329 const Expr *E);
330 bool visitArrayElemInit(unsigned ElemIndex, const Expr *Init,
331 OptPrimType InitT);
332 bool visitCallArgs(ArrayRef<const Expr *> Args, const FunctionDecl *FuncDecl,
333 bool Activate, bool IsOperatorCall);
334
335 /// Creates a local primitive value.
336 unsigned allocateLocalPrimitive(DeclTy &&Decl, PrimType Ty, bool IsConst,
337 bool IsVolatile = false,
339
340 /// Allocates a space storing a local given its type.
344
345private:
346 friend class VariableScope<Emitter>;
347 friend class LocalScope<Emitter>;
348 friend class DestructorScope<Emitter>;
349 friend class DeclScope<Emitter>;
350 friend class InitLinkScope<Emitter>;
351 friend class InitStackScope<Emitter>;
352 friend class OptionScope<Emitter>;
353 friend class ArrayIndexScope<Emitter>;
354 friend class SourceLocScope<Emitter>;
355 friend struct InitLink;
356 friend class LoopScope<Emitter>;
357 friend class LabelScope<Emitter>;
358 friend class SwitchScope<Emitter>;
359 friend class StmtExprScope<Emitter>;
360 friend class LocOverrideScope<Emitter>;
361
362 /// Emits a zero initializer.
363 bool visitZeroInitializer(PrimType T, QualType QT, const Expr *E);
364 bool visitZeroRecordInitializer(const Record *R, const Expr *E);
365 bool visitZeroArrayInitializer(QualType T, const Expr *E);
366 bool visitAssignment(const Expr *LHS, const Expr *RHS, const Expr *E);
367
368 /// Emits an APSInt constant.
369 bool emitConst(const llvm::APSInt &Value, PrimType Ty, const Expr *E);
370 bool emitConst(const llvm::APInt &Value, PrimType Ty, const Expr *E);
371 bool emitConst(const llvm::APSInt &Value, const Expr *E);
372 bool emitConst(const llvm::APInt &Value, const Expr *E) {
373 return emitConst(Value, classifyPrim(E), E);
374 }
375
376 /// Emits an integer constant.
377 template <typename T> bool emitConst(T Value, PrimType Ty, const Expr *E);
378 template <typename T> bool emitConst(T Value, const Expr *E);
379 bool emitBool(bool V, const Expr *E) override {
380 return this->emitConst(V, E);
381 }
382
383 llvm::RoundingMode getRoundingMode(const Expr *E) const {
385
386 if (FPO.getRoundingMode() == llvm::RoundingMode::Dynamic)
387 return llvm::RoundingMode::NearestTiesToEven;
388
389 return FPO.getRoundingMode();
390 }
391
392 uint32_t getFPOptions(const Expr *E) const {
393 return E->getFPFeaturesInEffect(Ctx.getLangOpts()).getAsOpaqueInt();
394 }
395
396 bool emitPrimCast(PrimType FromT, PrimType ToT, QualType ToQT, const Expr *E);
397 bool emitIntegralCast(PrimType FromT, PrimType ToT, QualType ToQT,
398 const Expr *E);
399 PrimType classifyComplexElementType(QualType T) const {
400 assert(T->isAnyComplexType());
401
402 QualType ElemType = T->getAs<ComplexType>()->getElementType();
403
404 return *this->classify(ElemType);
405 }
406
407 PrimType classifyVectorElementType(QualType T) const {
408 assert(T->isVectorType());
409 return *this->classify(T->getAs<VectorType>()->getElementType());
410 }
411
412 PrimType classifyMatrixElementType(QualType T) const {
413 assert(T->isMatrixType());
414 return *this->classify(T->getAs<MatrixType>()->getElementType());
415 }
416
417 bool emitComplexReal(const Expr *SubExpr);
418 bool emitComplexBoolCast(const Expr *E);
419 bool emitComplexComparison(const Expr *LHS, const Expr *RHS,
420 const BinaryOperator *E);
421 bool emitRecordDestructionPop(const Record *R, SourceInfo Loc);
422 bool emitDestructionPop(const Descriptor *Desc, SourceInfo Loc);
423 bool emitDummyPtr(const DeclTy &D, const Expr *E, bool CU = false);
424 bool emitFloat(const APFloat &F, const Expr *E);
425 unsigned collectBaseOffset(const QualType BaseType,
426 const QualType DerivedType);
427 bool emitLambdaStaticInvokerBody(const CXXMethodDecl *MD);
428 bool emitBuiltinBitCast(const CastExpr *E);
429
430 bool emitHLSLAggregateSplat(PrimType SrcT, unsigned SrcOffset,
431 QualType DestType, const Expr *E);
432 bool emitVectorConversion(const Expr *Src, const Expr *E);
433
434 /// A scalar element extracted during HLSL aggregate flattening.
435 struct HLSLFlatElement {
436 unsigned LocalOffset;
437 PrimType Type;
438 };
439 unsigned countHLSLFlatElements(QualType Ty);
440 bool emitHLSLFlattenAggregate(QualType SrcType, unsigned SrcPtrOffset,
441 SmallVectorImpl<HLSLFlatElement> &Elements,
442 unsigned MaxElements, const Expr *E);
443 bool emitHLSLConstructAggregate(QualType DestType,
444 ArrayRef<HLSLFlatElement> Elements,
445 unsigned &ElemIdx, const Expr *E);
446 bool emitHLSLConstructAggregate(QualType DestType,
447 ArrayRef<HLSLFlatElement> Elements,
448 const Expr *E) {
449 unsigned ElemIdx = 0;
450 return emitHLSLConstructAggregate(DestType, Elements, ElemIdx, E);
451 }
452
453 bool compileConstructor(const CXXConstructorDecl *Ctor);
454 bool compileDestructor(const CXXDestructorDecl *Dtor);
455 bool compileUnionAssignmentOperator(const CXXMethodDecl *MD);
456
457 bool checkLiteralType(const Expr *E);
458 bool maybeEmitDeferredVarInit(const VarDecl *VD);
459
460 bool refersToUnion(const Expr *E);
461
462protected:
463 /// Variable to storage mapping.
464 llvm::DenseMap<const ValueDecl *, Scope::Local> Locals;
465
466 /// OpaqueValueExpr to location mapping.
467 llvm::DenseMap<const OpaqueValueExpr *, unsigned> OpaqueExprs;
468
469 /// Current scope.
471
472 /// Current argument index. Needed to emit ArrayInitIndexExpr.
473 std::optional<uint64_t> ArrayIndex;
474
475 /// DefaultInit- or DefaultArgExpr, needed for SourceLocExpr.
476 const Expr *SourceLocDefaultExpr = nullptr;
477
478 /// Flag indicating if return value is to be discarded.
479 bool DiscardResult = false;
480
481 bool InStmtExpr = false;
482 bool ToLValue = false;
483
485
486 /// Flag inidicating if we're initializing an already created
487 /// variable. This is set in visitInitializer().
488 bool Initializing = false;
489 const ValueDecl *InitializingDecl = nullptr;
490
492 bool InitStackActive = false;
493
494 /// Type of the expression returned by the function.
496
497 /// Switch case mapping.
499 /// Stack of label information for loops and switch statements.
501
503};
504
505extern template class Compiler<ByteCodeEmitter>;
506extern template class Compiler<EvalEmitter>;
507
508/// Scope chain managing the variable lifetimes.
509template <class Emitter> class VariableScope {
510public:
512 : Ctx(Ctx), Parent(Ctx->VarScope), Kind(Kind) {
513 if (Parent)
514 this->LocalsAlwaysEnabled = Parent->LocalsAlwaysEnabled;
515 Ctx->VarScope = this;
516 }
517
518 virtual ~VariableScope() { Ctx->VarScope = this->Parent; }
519
520 virtual void addLocal(Scope::Local Local) {
521 llvm_unreachable("Shouldn't be called");
522 }
523 /// Like addExtended, but adds to the nearest scope of the given kind.
525 VariableScope *P = this;
526 while (P) {
527 // We found the right scope kind.
528 if (P->Kind == Kind) {
529 P->addLocal(Local);
530 return;
531 }
532 // If we reached the root scope and we're looking for a Block scope,
533 // attach it to the root instead of the current scope.
534 if (!P->Parent && Kind == ScopeKind::Block) {
535 P->addLocal(Local);
536 return;
537 }
538 P = P->Parent;
539 if (!P)
540 break;
541 }
542
543 // Add to this scope.
544 this->addLocal(Local);
545 }
546
547 virtual bool emitDestructors(const Expr *E = nullptr) { return true; }
548 virtual bool destroyLocals(const Expr *E = nullptr) { return true; }
549 virtual void forceInit() {}
550 VariableScope *getParent() const { return Parent; }
551 ScopeKind getKind() const { return Kind; }
552
553 /// Whether locals added to this scope are enabled by default.
554 /// This is almost always true, except for the two branches
555 /// of a conditional operator.
557
558protected:
559 /// Compiler instance.
561 /// Link to the parent scope.
564};
565
566/// Generic scope for local variables.
567template <class Emitter> class LocalScope : public VariableScope<Emitter> {
568public:
571
572 /// Emit a Destroy op for this scope.
573 ~LocalScope() override {
574 if (!Idx)
575 return;
576 this->Ctx->emitDestroy(*Idx, SourceInfo{});
578 }
579 /// Explicit destruction of local variables.
580 bool destroyLocals(const Expr *E = nullptr) override {
581 if (!Idx)
582 return true;
583
584 // NB: We are *not* resetting Idx here as to allow multiple
585 // calls to destroyLocals().
586 bool Success = this->emitDestructors(E);
587 this->Ctx->emitDestroy(*Idx, E);
588 return Success;
589 }
590
591 void addLocal(Scope::Local Local) override {
592 if (!Idx) {
593 Idx = static_cast<unsigned>(this->Ctx->Descriptors.size());
594 this->Ctx->Descriptors.emplace_back();
595 this->Ctx->emitInitScope(*Idx, {});
596 }
597
598 Local.EnabledByDefault = this->LocalsAlwaysEnabled;
599 this->Ctx->Descriptors[*Idx].emplace_back(Local);
600 }
601
602 /// Force-initialize this scope. Usually, scopes are lazily initialized when
603 /// the first local variable is created, but in scenarios with conditonal
604 /// operators, we need to ensure scope is initialized just in case one of the
605 /// arms will create a local and the other won't. In such a case, the
606 /// InitScope() op would be part of the arm that created the local.
607 void forceInit() override {
608 if (!Idx) {
609 Idx = static_cast<unsigned>(this->Ctx->Descriptors.size());
610 this->Ctx->Descriptors.emplace_back();
611 this->Ctx->emitInitScope(*Idx, {});
612 }
613 }
614
615 bool emitDestructors(const Expr *E = nullptr) override {
616 if (!Idx)
617 return true;
618
619 // Emit destructor calls for local variables of record
620 // type with a destructor.
621 for (Scope::Local &Local : llvm::reverse(this->Ctx->Descriptors[*Idx])) {
622 if (Local.Desc->hasTrivialDtor())
623 continue;
624
625 if (!Local.EnabledByDefault) {
626 typename Emitter::LabelTy EndLabel = this->Ctx->getLabel();
627 if (!this->Ctx->emitGetLocalEnabled(Local.Offset, E))
628 return false;
629 if (!this->Ctx->jumpFalse(EndLabel, E))
630 return false;
631
632 if (!this->Ctx->emitGetPtrLocal(Local.Offset, E))
633 return false;
634
635 if (!this->Ctx->emitDestructionPop(Local.Desc, Local.Desc->getLoc()))
636 return false;
637
638 this->Ctx->fallthrough(EndLabel);
639 this->Ctx->emitLabel(EndLabel);
640 } else {
641 if (!this->Ctx->emitGetPtrLocal(Local.Offset, E))
642 return false;
643 if (!this->Ctx->emitDestructionPop(Local.Desc, Local.Desc->getLoc()))
644 return false;
645 }
646
648 }
649 return true;
650 }
651
653 if (!Idx)
654 return;
655
656 for (const Scope::Local &Local : this->Ctx->Descriptors[*Idx]) {
658 }
659 }
660
662 if (const auto *OVE =
663 llvm::dyn_cast_if_present<OpaqueValueExpr>(Local.Desc->asExpr())) {
664 if (auto It = this->Ctx->OpaqueExprs.find(OVE);
665 It != this->Ctx->OpaqueExprs.end())
666 this->Ctx->OpaqueExprs.erase(It);
667 };
668 }
669
670 /// Index of the scope in the chain.
671 UnsignedOrNone Idx = std::nullopt;
672};
673
674template <class Emitter> class ArrayIndexScope final {
675public:
676 ArrayIndexScope(Compiler<Emitter> *Ctx, uint64_t Index) : Ctx(Ctx) {
677 OldArrayIndex = Ctx->ArrayIndex;
678 Ctx->ArrayIndex = Index;
679 }
680
681 ~ArrayIndexScope() { Ctx->ArrayIndex = OldArrayIndex; }
682
683private:
685 std::optional<uint64_t> OldArrayIndex;
686};
687
688template <class Emitter> class SourceLocScope final {
689public:
690 SourceLocScope(Compiler<Emitter> *Ctx, const Expr *DefaultExpr) : Ctx(Ctx) {
691 assert(DefaultExpr);
692 // We only switch if the current SourceLocDefaultExpr is null.
693 if (!Ctx->SourceLocDefaultExpr) {
694 Enabled = true;
695 Ctx->SourceLocDefaultExpr = DefaultExpr;
696 }
697 }
698
700 if (Enabled)
701 Ctx->SourceLocDefaultExpr = nullptr;
702 }
703
704private:
706 bool Enabled = false;
707};
708
709template <class Emitter> class InitLinkScope final {
710public:
712 Ctx->InitStack.push_back(std::move(Link));
713 }
714
715 ~InitLinkScope() { this->Ctx->InitStack.pop_back(); }
716
717public:
719};
720
721template <class Emitter> class InitStackScope final {
722public:
724 : Ctx(Ctx), OldValue(Ctx->InitStackActive), Active(Active) {
725 Ctx->InitStackActive = Active;
726 if (Active)
727 Ctx->InitStack.push_back(InitLink::DIE());
728 }
729
731 this->Ctx->InitStackActive = OldValue;
732 if (Active)
733 Ctx->InitStack.pop_back();
734 }
735
736private:
738 bool OldValue;
739 bool Active;
740};
741
742} // namespace interp
743} // namespace clang
744
745#endif
#define V(N, I)
llvm::MachO::Record Record
Definition MachO.h:31
__device__ __2f16 b
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Definition APValue.h:122
AbstractConditionalOperator - An abstract base class for ConditionalOperator and BinaryConditionalOpe...
Definition Expr.h:4356
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition Expr.h:4553
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition Expr.h:6021
Represents a loop initializing the elements of an array.
Definition Expr.h:5968
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2724
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Definition ExprCXX.h:3000
Represents an attribute applied to a statement.
Definition Stmt.h:2213
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:4041
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition Expr.h:6672
BreakStmt - This represents a break.
Definition Stmt.h:3145
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition ExprCXX.h:5472
Represents binding an expression to a temporary.
Definition ExprCXX.h:1497
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition ExprCXX.h:727
Represents a call to a C++ constructor.
Definition ExprCXX.h:1552
A default argument (C++ [dcl.fct.default]).
Definition ExprCXX.h:1274
A use of a default initializer in a constructor or in aggregate initialization.
Definition ExprCXX.h:1381
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition ExprCXX.h:2630
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition ExprCXX.h:485
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Definition StmtCXX.h:135
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition ExprCXX.h:1755
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition ExprCXX.h:2359
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition ExprCXX.h:4309
The null pointer literal (C++11 [lex.nullptr])
Definition ExprCXX.h:772
Represents a list-initialization with parenthesis.
Definition ExprCXX.h:5141
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition ExprCXX.h:530
A rewritten comparison expression that was originally written using operator syntax.
Definition ExprCXX.h:290
An expression "T()" which creates an rvalue of a non-class type T.
Definition ExprCXX.h:2200
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition ExprCXX.h:804
Represents the this expression in C++.
Definition ExprCXX.h:1158
A C++ throw-expression (C++ [except.throw]).
Definition ExprCXX.h:1212
CXXTryStmt - A C++ try block, including all handlers.
Definition StmtCXX.h:69
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Definition ExprCXX.h:852
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition ExprCXX.h:1072
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:2946
CaseStmt - Represent a case statement.
Definition Stmt.h:1930
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition Expr.h:3679
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition Expr.h:4851
CompoundAssignOperator - For compound assignments (e.g.
Definition Expr.h:4303
CompoundLiteralExpr - [C99 6.5.2.5].
Definition Expr.h:3608
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition Stmt.h:1750
Represents the specialization of a concept - evaluates to a prvalue of type bool.
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition Expr.h:1085
ContinueStmt - This represents a continue.
Definition Stmt.h:3129
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition Expr.h:4722
A reference to a declared variable, function, enum, etc.
Definition Expr.h:1273
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition Stmt.h:1641
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
DoStmt - This represents a 'do/while' stmt.
Definition Stmt.h:2842
Represents a reference to emded data.
Definition Expr.h:5129
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition ExprCXX.h:3661
This represents one expression.
Definition Expr.h:112
FPOptions getFPFeaturesInEffect(const LangOptions &LO) const
Returns the set of floating point options that apply to this expression.
Definition Expr.cpp:3996
An expression trait intrinsic.
Definition ExprCXX.h:3073
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition Expr.h:6610
RoundingMode getRoundingMode() const
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition Stmt.h:2898
Represents a function declaration or definition.
Definition Decl.h:2018
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition Expr.h:4926
Represents a C11 generic selection.
Definition Expr.h:6182
IfStmt - This represents an if/then/else.
Definition Stmt.h:2269
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
Definition Expr.h:1734
Represents an implicitly-generated value initialization of an object of a given type.
Definition Expr.h:6057
Describes an C or C++ initializer list.
Definition Expr.h:5302
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition ExprCXX.h:1972
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition ExprCXX.h:4920
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3367
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
Definition ExprObjC.h:220
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition ExprObjC.h:119
ObjCBoxedExpr - used for generalized expression boxing.
Definition ExprObjC.h:159
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition ExprObjC.h:342
ObjCEncodeExpr, used for @encode in Objective-C.
Definition ExprObjC.h:441
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition ExprObjC.h:84
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
Definition Expr.h:2530
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition Expr.h:1181
ParenExpr - This represents a parenthesized expression, e.g.
Definition Expr.h:2185
[C99 6.4.2.2] - A predefined identifier such as func.
Definition Expr.h:2008
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition Expr.h:6804
A (possibly-)qualified type.
Definition TypeBase.h:937
Represents a struct/union/class.
Definition Decl.h:4347
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
Definition Expr.h:7503
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition Stmt.h:3170
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition Expr.h:4646
Represents an expression that computes the length of a parameter pack.
Definition ExprCXX.h:4441
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Definition Expr.h:5020
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition Expr.h:4598
Stmt - This represents one statement.
Definition Stmt.h:86
StringLiteral - This represents a string literal expression, e.g.
Definition Expr.h:1802
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition ExprCXX.h:4664
SwitchStmt - This represents a 'switch' stmt.
Definition Stmt.h:2519
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition ExprCXX.h:2900
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition Expr.h:2628
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2247
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition Decl.h:712
Represents a variable declaration or definition.
Definition Decl.h:924
WhileStmt - This represents a 'while' stmt.
Definition Stmt.h:2707
ArrayIndexScope(Compiler< Emitter > *Ctx, uint64_t Index)
Definition Compiler.h:676
A memory block, either on the stack or in the heap.
Definition InterpBlock.h:44
Compilation context for expressions.
Definition Compiler.h:112
llvm::SmallVector< InitLink > InitStack
Definition Compiler.h:491
bool VisitArrayInitIndexExpr(const ArrayInitIndexExpr *E)
bool VisitCXXDeleteExpr(const CXXDeleteExpr *E)
bool VisitOffsetOfExpr(const OffsetOfExpr *E)
bool visitContinueStmt(const ContinueStmt *S)
bool VisitCharacterLiteral(const CharacterLiteral *E)
PrimType classifyPrim(const Expr *E) const
Classifies a known primitive expression.
Definition Compiler.h:292
bool visitArrayElemInit(unsigned ElemIndex, const Expr *Init, OptPrimType InitT)
Pointer to the array(not the element!) must be on the stack when calling this.
UnsignedOrNone allocateLocal(DeclTy &&Decl, QualType Ty=QualType(), ScopeKind=ScopeKind::Block)
Allocates a space storing a local given its type.
bool VisitCXXParenListInitExpr(const CXXParenListInitExpr *E)
bool VisitConceptSpecializationExpr(const ConceptSpecializationExpr *E)
bool visitInitializerPop(const Expr *E)
Similar, but will also pop the pointer.
bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E)
bool visitBool(const Expr *E)
Visits an expression and converts it to a boolean.
bool VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *E)
PrimType classifyPrim(QualType Ty) const
Classifies a known primitive type.
Definition Compiler.h:285
bool VisitTypeTraitExpr(const TypeTraitExpr *E)
bool VisitLambdaExpr(const LambdaExpr *E)
bool VisitMemberExpr(const MemberExpr *E)
llvm::DenseMap< const OpaqueValueExpr *, unsigned > OpaqueExprs
OpaqueValueExpr to location mapping.
Definition Compiler.h:467
bool VisitBinaryOperator(const BinaryOperator *E)
bool visitAttributedStmt(const AttributedStmt *S)
bool VisitPackIndexingExpr(const PackIndexingExpr *E)
bool visitAPValueInitializer(const APValue &Val, const Expr *E, QualType T)
bool VisitArraySubscriptExpr(const ArraySubscriptExpr *E)
bool VisitCallExpr(const CallExpr *E)
std::optional< uint64_t > ArrayIndex
Current argument index. Needed to emit ArrayInitIndexExpr.
Definition Compiler.h:473
bool VisitPseudoObjectExpr(const PseudoObjectExpr *E)
bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E)
const Function * getFunction(const FunctionDecl *FD)
Returns a function for the given FunctionDecl.
bool VisitFixedPointBinOp(const BinaryOperator *E)
bool VisitCastExpr(const CastExpr *E)
Definition Compiler.cpp:213
bool VisitObjCEncodeExpr(const ObjCEncodeExpr *E)
bool VisitFixedPointUnaryOperator(const UnaryOperator *E)
unsigned allocateLocalPrimitive(DeclTy &&Decl, PrimType Ty, bool IsConst, bool IsVolatile=false, ScopeKind SC=ScopeKind::Block)
Creates a local primitive value.
bool VisitComplexUnaryOperator(const UnaryOperator *E)
llvm::DenseMap< const SwitchCase *, LabelTy > CaseMap
Definition Compiler.h:118
bool VisitBlockExpr(const BlockExpr *E)
friend struct InitLink
Definition Compiler.h:355
bool visitAPValue(const APValue &Val, PrimType ValType, const Expr *E)
Visit an APValue.
bool VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *E)
bool VisitLogicalBinOp(const BinaryOperator *E)
bool visitCompoundStmt(const CompoundStmt *S)
Context & Ctx
Current compilation context.
Definition Compiler.h:135
bool visitDeclRef(const ValueDecl *D, const Expr *E)
Visit the given decl as if we have a reference to it.
bool visitBreakStmt(const BreakStmt *S)
bool visitExpr(const Expr *E, bool DestroyToplevelScope) override
bool visitForStmt(const ForStmt *S)
bool VisitDeclRefExpr(const DeclRefExpr *E)
bool VisitOpaqueValueExpr(const OpaqueValueExpr *E)
bool VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E)
bool VisitStmtExpr(const StmtExpr *E)
bool VisitBuiltinBitCastExpr(const BuiltinBitCastExpr *E)
bool VisitFixedPointLiteral(const FixedPointLiteral *E)
const FunctionDecl * CompilingFunction
Definition Compiler.h:502
bool VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E)
VarCreationState visitVarDecl(const VarDecl *VD, const Expr *Init, bool Toplevel=false)
Creates and initializes a variable from the given decl.
VariableScope< Emitter > * VarScope
Current scope.
Definition Compiler.h:470
bool visitDeclAndReturn(const VarDecl *VD, const Expr *Init, bool ConstantContext) override
Toplevel visitDeclAndReturn().
bool VisitCXXNewExpr(const CXXNewExpr *E)
const ValueDecl * InitializingDecl
Definition Compiler.h:489
bool VisitCompoundAssignOperator(const CompoundAssignOperator *E)
bool visit(const Expr *E) override
Evaluates an expression and places the result on the stack.
bool delegate(const Expr *E)
Just pass evaluation on to E.
bool visitLValueExpr(const Expr *E, bool DestroyToplevelScope) override
bool discard(const Expr *E)
Evaluates an expression for side effects and discards the result.
bool VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *E)
CaseMap CaseLabels
Switch case mapping.
Definition Compiler.h:498
Record * getRecord(QualType Ty)
Returns a record from a record or pointer type.
const RecordType * getRecordTy(QualType Ty)
Returns a record type from a record or pointer type.
bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E)
bool visitInitList(ArrayRef< const Expr * > Inits, const Expr *ArrayFiller, const Expr *E)
bool VisitSizeOfPackExpr(const SizeOfPackExpr *E)
bool VisitPredefinedExpr(const PredefinedExpr *E)
bool VisitSourceLocExpr(const SourceLocExpr *E)
Compiler(Context &Ctx, Program &P, Tys &&...Args)
Initializes the compiler and the backend emitter.
Definition Compiler.h:142
bool visitDeclStmt(const DeclStmt *DS, bool EvaluateConditionDecl=false)
bool emitCleanup()
Emits scope cleanup instructions.
bool VisitExtVectorElementExpr(const ExtVectorElementExpr *E)
bool VisitObjCStringLiteral(const ObjCStringLiteral *E)
bool VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *E)
bool visitInitializer(const Expr *E)
Compiles an initializer.
bool visitDtorCall(const VarDecl *VD, const APValue &Value) override
const Expr * SourceLocDefaultExpr
DefaultInit- or DefaultArgExpr, needed for SourceLocExpr.
Definition Compiler.h:476
bool VisitObjCArrayLiteral(const ObjCArrayLiteral *E)
UnsignedOrNone OptLabelTy
Definition Compiler.h:117
bool VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *E)
bool VisitPointerArithBinOp(const BinaryOperator *E)
Perform addition/subtraction of a pointer and an integer or subtraction of two pointers.
bool visitCallArgs(ArrayRef< const Expr * > Args, const FunctionDecl *FuncDecl, bool Activate, bool IsOperatorCall)
bool VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *E)
bool visitDefaultStmt(const DefaultStmt *S)
bool VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E)
typename Emitter::LabelTy LabelTy
Definition Compiler.h:115
VarCreationState visitDecl(const VarDecl *VD)
bool VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *E)
bool visitStmt(const Stmt *S)
bool VisitExpressionTraitExpr(const ExpressionTraitExpr *E)
bool VisitVectorUnaryOperator(const UnaryOperator *E)
bool VisitCXXConstructExpr(const CXXConstructExpr *E)
bool VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E)
bool VisitObjCBoxedExpr(const ObjCBoxedExpr *E)
bool VisitDesignatedInitUpdateExpr(const DesignatedInitUpdateExpr *E)
bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E)
bool VisitRecoveryExpr(const RecoveryExpr *E)
bool VisitRequiresExpr(const RequiresExpr *E)
bool Initializing
Flag inidicating if we're initializing an already created variable.
Definition Compiler.h:488
bool visitReturnStmt(const ReturnStmt *RS)
bool VisitCXXThrowExpr(const CXXThrowExpr *E)
bool VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E)
bool VisitChooseExpr(const ChooseExpr *E)
bool visitFunc(const FunctionDecl *F) override
bool visitCXXForRangeStmt(const CXXForRangeStmt *S)
bool visitCaseStmt(const CaseStmt *S)
bool VisitComplexBinOp(const BinaryOperator *E)
llvm::DenseMap< const ValueDecl *, Scope::Local > Locals
Variable to storage mapping.
Definition Compiler.h:464
bool VisitAbstractConditionalOperator(const AbstractConditionalOperator *E)
bool VisitCXXTypeidExpr(const CXXTypeidExpr *E)
UnsignedOrNone allocateTemporary(const Expr *E)
bool VisitBuiltinCallExpr(const CallExpr *E, unsigned BuiltinID)
bool VisitImplicitValueInitExpr(const ImplicitValueInitExpr *E)
typename Emitter::AddrTy AddrTy
Definition Compiler.h:116
bool VisitCXXRewrittenBinaryOperator(const CXXRewrittenBinaryOperator *E)
OptPrimType classify(QualType Ty) const
Definition Compiler.h:280
OptPrimType ReturnType
Type of the expression returned by the function.
Definition Compiler.h:495
bool VisitUnaryOperator(const UnaryOperator *E)
bool VisitFloatCompoundAssignOperator(const CompoundAssignOperator *E)
OptPrimType classify(const Expr *E) const
Definition Compiler.h:279
llvm::SmallVector< LabelInfo > LabelInfoStack
Stack of label information for loops and switch statements.
Definition Compiler.h:500
bool VisitGenericSelectionExpr(const GenericSelectionExpr *E)
bool visitDoStmt(const DoStmt *S)
bool VisitIntegerLiteral(const IntegerLiteral *E)
bool VisitInitListExpr(const InitListExpr *E)
bool VisitVectorBinOp(const BinaryOperator *E)
bool VisitStringLiteral(const StringLiteral *E)
bool VisitParenExpr(const ParenExpr *E)
bool VisitCXXNoexceptExpr(const CXXNoexceptExpr *E)
bool VisitShuffleVectorExpr(const ShuffleVectorExpr *E)
bool VisitPointerCompoundAssignOperator(const CompoundAssignOperator *E)
bool DiscardResult
Flag indicating if return value is to be discarded.
Definition Compiler.h:479
bool VisitEmbedExpr(const EmbedExpr *E)
bool VisitConvertVectorExpr(const ConvertVectorExpr *E)
bool VisitCXXThisExpr(const CXXThisExpr *E)
bool VisitConstantExpr(const ConstantExpr *E)
bool VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *E)
bool visitSwitchStmt(const SwitchStmt *S)
bool canClassify(QualType T) const
Definition Compiler.h:282
bool VisitCXXUuidofExpr(const CXXUuidofExpr *E)
bool VisitExprWithCleanups(const ExprWithCleanups *E)
bool visitAsLValue(const Expr *E)
bool visitWhileStmt(const WhileStmt *S)
bool visitIfStmt(const IfStmt *IS)
bool VisitAddrLabelExpr(const AddrLabelExpr *E)
bool canClassify(const Expr *E) const
Definition Compiler.h:281
bool VisitFloatingLiteral(const FloatingLiteral *E)
Program & P
Program to link to.
Definition Compiler.h:137
bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E)
bool VisitGNUNullExpr(const GNUNullExpr *E)
bool VisitImaginaryLiteral(const ImaginaryLiteral *E)
bool VisitSYCLUniqueStableNameExpr(const SYCLUniqueStableNameExpr *E)
bool visitCXXTryStmt(const CXXTryStmt *S)
Holds all information required to evaluate constexpr code in a module.
Definition Context.h:47
const LangOptions & getLangOpts() const
Returns the language options.
Definition Context.cpp:390
Scope used to handle temporaries in toplevel variable declarations.
Definition Compiler.cpp:40
Bytecode function.
Definition Function.h:99
InitLinkScope(Compiler< Emitter > *Ctx, InitLink &&Link)
Definition Compiler.h:711
Compiler< Emitter > * Ctx
Definition Compiler.h:718
InitStackScope(Compiler< Emitter > *Ctx, bool Active)
Definition Compiler.h:723
When generating code for e.g.
Definition Compiler.cpp:188
Generic scope for local variables.
Definition Compiler.h:567
UnsignedOrNone Idx
Index of the scope in the chain.
Definition Compiler.h:671
~LocalScope() override
Emit a Destroy op for this scope.
Definition Compiler.h:573
bool destroyLocals(const Expr *E=nullptr) override
Explicit destruction of local variables.
Definition Compiler.h:580
bool emitDestructors(const Expr *E=nullptr) override
Definition Compiler.h:615
void removeIfStoredOpaqueValue(const Scope::Local &Local)
Definition Compiler.h:661
void addLocal(Scope::Local Local) override
Definition Compiler.h:591
void forceInit() override
Force-initialize this scope.
Definition Compiler.h:607
LocalScope(Compiler< Emitter > *Ctx, ScopeKind Kind=ScopeKind::Block)
Definition Compiler.h:569
Sets the context for break/continue statements.
Definition Compiler.cpp:114
Scope used to handle initialization methods.
Definition Compiler.cpp:60
The program contains and links the bytecode for all functions.
Definition Program.h:36
Structure/Class descriptor.
Definition Record.h:25
Describes the statement/declaration an opcode was generated from.
Definition Source.h:74
SourceLocScope(Compiler< Emitter > *Ctx, const Expr *DefaultExpr)
Definition Compiler.h:690
Scope chain managing the variable lifetimes.
Definition Compiler.h:509
void addForScopeKind(const Scope::Local &Local, ScopeKind Kind)
Like addExtended, but adds to the nearest scope of the given kind.
Definition Compiler.h:524
bool LocalsAlwaysEnabled
Whether locals added to this scope are enabled by default.
Definition Compiler.h:556
Compiler< Emitter > * Ctx
Compiler instance.
Definition Compiler.h:560
virtual bool emitDestructors(const Expr *E=nullptr)
Definition Compiler.h:547
VariableScope(Compiler< Emitter > *Ctx, ScopeKind Kind=ScopeKind::Block)
Definition Compiler.h:511
virtual bool destroyLocals(const Expr *E=nullptr)
Definition Compiler.h:548
virtual void addLocal(Scope::Local Local)
Definition Compiler.h:520
VariableScope * Parent
Link to the parent scope.
Definition Compiler.h:562
ScopeKind getKind() const
Definition Compiler.h:551
VariableScope * getParent() const
Definition Compiler.h:550
bool Call(InterpState &S, CodePtr OpPC, const Function *Func, uint32_t VarArgSize)
Definition Interp.cpp:1786
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
Definition Descriptor.h:29
static bool Activate(InterpState &S, CodePtr OpPC)
Definition Interp.h:2206
llvm::APFloat APFloat
Definition Floating.h:27
PrimType
Enumeration of the primitive types of the VM.
Definition PrimType.h:34
bool Init(InterpState &S, CodePtr OpPC)
Definition Interp.h:2323
The JSON file list parser is used to communicate input to InstallAPI.
@ Success
Annotation was successful.
Definition Parser.h:65
@ Link
'link' clause, allowed on 'declare' construct.
OptionalUnsigned< unsigned > UnsignedOrNone
const VariableScope< Emitter > * BreakOrContinueScope
Definition Compiler.h:122
LabelInfo(const Stmt *Name, OptLabelTy BreakLabel, OptLabelTy ContinueLabel, OptLabelTy DefaultLabel, const VariableScope< Emitter > *BreakOrContinueScope)
Definition Compiler.h:126
Information about a local's storage.
Definition Function.h:39
State encapsulating if a the variable creation has been successful, unsuccessful, or no variable has ...
Definition Compiler.h:97
static VarCreationState NotCreated()
Definition Compiler.h:101
std::optional< bool > S
Definition Compiler.h:98