clang 20.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"
25
26namespace clang {
27class QualType;
28
29namespace interp {
30
31template <class Emitter> class LocalScope;
32template <class Emitter> class DestructorScope;
33template <class Emitter> class VariableScope;
34template <class Emitter> class DeclScope;
35template <class Emitter> class InitLinkScope;
36template <class Emitter> class InitStackScope;
37template <class Emitter> class OptionScope;
38template <class Emitter> class ArrayIndexScope;
39template <class Emitter> class SourceLocScope;
40template <class Emitter> class LoopScope;
41template <class Emitter> class LabelScope;
42template <class Emitter> class SwitchScope;
43template <class Emitter> class StmtExprScope;
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 };
55
56 static InitLink This() { return InitLink{K_This}; }
57 static InitLink Field(unsigned Offset) {
58 InitLink IL{K_Field};
59 IL.Offset = Offset;
60 return IL;
61 }
62 static InitLink Temp(unsigned Offset) {
63 InitLink IL{K_Temp};
64 IL.Offset = Offset;
65 return IL;
66 }
67 static InitLink Decl(const ValueDecl *D) {
68 InitLink IL{K_Decl};
69 IL.D = D;
70 return IL;
71 }
72 static InitLink Elem(unsigned Index) {
73 InitLink IL{K_Elem};
74 IL.Offset = Index;
75 return IL;
76 }
77
78 InitLink(uint8_t Kind) : Kind(Kind) {}
79 template <class Emitter>
80 bool emit(Compiler<Emitter> *Ctx, const Expr *E) const;
81
82 uint32_t Kind;
83 union {
84 unsigned Offset;
85 const ValueDecl *D;
86 };
87};
88
89/// State encapsulating if a the variable creation has been successful,
90/// unsuccessful, or no variable has been created at all.
92 std::optional<bool> S = std::nullopt;
93 VarCreationState() = default;
94 VarCreationState(bool b) : S(b) {}
96
97 operator bool() const { return S && *S; }
98 bool notCreated() const { return !S; }
99};
100
101/// Compilation context for expressions.
102template <class Emitter>
103class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
104 public Emitter {
105protected:
106 // Aliases for types defined in the emitter.
107 using LabelTy = typename Emitter::LabelTy;
108 using AddrTy = typename Emitter::AddrTy;
109 using OptLabelTy = std::optional<LabelTy>;
110 using CaseMap = llvm::DenseMap<const SwitchCase *, LabelTy>;
111
112 /// Current compilation context.
114 /// Program to link to.
116
117public:
118 /// Initializes the compiler and the backend emitter.
119 template <typename... Tys>
120 Compiler(Context &Ctx, Program &P, Tys &&...Args)
121 : Emitter(Ctx, P, Args...), Ctx(Ctx), P(P) {}
122
123 // Expressions.
124 bool VisitCastExpr(const CastExpr *E);
129 bool VisitParenExpr(const ParenExpr *E);
134 bool VisitVectorBinOp(const BinaryOperator *E);
138 bool VisitCallExpr(const CallExpr *E);
139 bool VisitBuiltinCallExpr(const CallExpr *E, unsigned BuiltinID);
143 bool VisitGNUNullExpr(const GNUNullExpr *E);
144 bool VisitCXXThisExpr(const CXXThisExpr *E);
148 bool VisitDeclRefExpr(const DeclRefExpr *E);
152 bool VisitInitListExpr(const InitListExpr *E);
154 bool VisitConstantExpr(const ConstantExpr *E);
156 bool VisitMemberExpr(const MemberExpr *E);
175 bool VisitLambdaExpr(const LambdaExpr *E);
177 bool VisitCXXThrowExpr(const CXXThrowExpr *E);
182 bool VisitOffsetOfExpr(const OffsetOfExpr *E);
186 bool VisitChooseExpr(const ChooseExpr *E);
187 bool VisitEmbedExpr(const EmbedExpr *E);
192 bool VisitRequiresExpr(const RequiresExpr *E);
197 bool VisitRecoveryExpr(const RecoveryExpr *E);
204 bool VisitStmtExpr(const StmtExpr *E);
205 bool VisitCXXNewExpr(const CXXNewExpr *E);
207 bool VisitBlockExpr(const BlockExpr *E);
208
209 // Statements.
210 bool visitCompoundStmt(const CompoundStmt *S);
211 bool visitDeclStmt(const DeclStmt *DS);
212 bool visitReturnStmt(const ReturnStmt *RS);
213 bool visitIfStmt(const IfStmt *IS);
214 bool visitWhileStmt(const WhileStmt *S);
215 bool visitDoStmt(const DoStmt *S);
216 bool visitForStmt(const ForStmt *S);
218 bool visitBreakStmt(const BreakStmt *S);
219 bool visitContinueStmt(const ContinueStmt *S);
220 bool visitSwitchStmt(const SwitchStmt *S);
221 bool visitCaseStmt(const CaseStmt *S);
222 bool visitDefaultStmt(const DefaultStmt *S);
223 bool visitAttributedStmt(const AttributedStmt *S);
224 bool visitCXXTryStmt(const CXXTryStmt *S);
225
226protected:
227 bool visitStmt(const Stmt *S);
228 bool visitExpr(const Expr *E, bool DestroyToplevelScope) override;
229 bool visitFunc(const FunctionDecl *F) override;
230
231 bool visitDeclAndReturn(const VarDecl *VD, bool ConstantContext) override;
232
233protected:
234 /// Emits scope cleanup instructions.
235 void emitCleanup();
236
237 /// Returns a record type from a record or pointer type.
239
240 /// Returns a record from a record or pointer type.
242 Record *getRecord(const RecordDecl *RD);
243
244 /// Returns a function for the given FunctionDecl.
245 /// If the function does not exist yet, it is compiled.
246 const Function *getFunction(const FunctionDecl *FD);
247
248 std::optional<PrimType> classify(const Expr *E) const {
249 return Ctx.classify(E);
250 }
251 std::optional<PrimType> classify(QualType Ty) const {
252 return Ctx.classify(Ty);
253 }
254
255 /// Classifies a known primitive type.
257 if (auto T = classify(Ty)) {
258 return *T;
259 }
260 llvm_unreachable("not a primitive type");
261 }
262 /// Classifies a known primitive expression.
263 PrimType classifyPrim(const Expr *E) const {
264 if (auto T = classify(E))
265 return *T;
266 llvm_unreachable("not a primitive type");
267 }
268
269 /// Evaluates an expression and places the result on the stack. If the
270 /// expression is of composite type, a local variable will be created
271 /// and a pointer to said variable will be placed on the stack.
272 bool visit(const Expr *E);
273 /// Compiles an initializer. This is like visit() but it will never
274 /// create a variable and instead rely on a variable already having
275 /// been created. visitInitializer() then relies on a pointer to this
276 /// variable being on top of the stack.
277 bool visitInitializer(const Expr *E);
278 /// Evaluates an expression for side effects and discards the result.
279 bool discard(const Expr *E);
280 /// Just pass evaluation on to \p E. This leaves all the parsing flags
281 /// intact.
282 bool delegate(const Expr *E);
283 /// Creates and initializes a variable from the given decl.
284 VarCreationState visitVarDecl(const VarDecl *VD, bool Toplevel = false);
286 /// Visit an APValue.
287 bool visitAPValue(const APValue &Val, PrimType ValType, const Expr *E);
288 bool visitAPValueInitializer(const APValue &Val, const Expr *E);
289 /// Visit the given decl as if we have a reference to it.
290 bool visitDeclRef(const ValueDecl *D, const Expr *E);
291
292 /// Visits an expression and converts it to a boolean.
293 bool visitBool(const Expr *E);
294
295 bool visitInitList(ArrayRef<const Expr *> Inits, const Expr *ArrayFiller,
296 const Expr *E);
297 bool visitArrayElemInit(unsigned ElemIndex, const Expr *Init);
298
299 /// Creates a local primitive value.
300 unsigned allocateLocalPrimitive(DeclTy &&Decl, PrimType Ty, bool IsConst,
301 bool IsExtended = false);
302
303 /// Allocates a space storing a local given its type.
304 std::optional<unsigned>
306 const ValueDecl *ExtendingDecl = nullptr);
307 unsigned allocateTemporary(const Expr *E);
308
309private:
310 friend class VariableScope<Emitter>;
311 friend class LocalScope<Emitter>;
312 friend class DestructorScope<Emitter>;
313 friend class DeclScope<Emitter>;
314 friend class InitLinkScope<Emitter>;
315 friend class InitStackScope<Emitter>;
316 friend class OptionScope<Emitter>;
317 friend class ArrayIndexScope<Emitter>;
318 friend class SourceLocScope<Emitter>;
319 friend struct InitLink;
320 friend class LoopScope<Emitter>;
321 friend class LabelScope<Emitter>;
322 friend class SwitchScope<Emitter>;
323 friend class StmtExprScope<Emitter>;
324
325 /// Emits a zero initializer.
326 bool visitZeroInitializer(PrimType T, QualType QT, const Expr *E);
327 bool visitZeroRecordInitializer(const Record *R, const Expr *E);
328 bool visitZeroArrayInitializer(QualType T, const Expr *E);
329
330 /// Emits an APSInt constant.
331 bool emitConst(const llvm::APSInt &Value, PrimType Ty, const Expr *E);
332 bool emitConst(const llvm::APSInt &Value, const Expr *E);
333 bool emitConst(const llvm::APInt &Value, const Expr *E) {
334 return emitConst(static_cast<llvm::APSInt>(Value), E);
335 }
336
337 /// Emits an integer constant.
338 template <typename T> bool emitConst(T Value, PrimType Ty, const Expr *E);
339 template <typename T> bool emitConst(T Value, const Expr *E);
340
341 llvm::RoundingMode getRoundingMode(const Expr *E) const {
342 FPOptions FPO = E->getFPFeaturesInEffect(Ctx.getLangOpts());
343
344 if (FPO.getRoundingMode() == llvm::RoundingMode::Dynamic)
345 return llvm::RoundingMode::NearestTiesToEven;
346
347 return FPO.getRoundingMode();
348 }
349
350 uint32_t getFPOptions(const Expr *E) const {
351 return E->getFPFeaturesInEffect(Ctx.getLangOpts()).getAsOpaqueInt();
352 }
353
354 bool emitPrimCast(PrimType FromT, PrimType ToT, QualType ToQT, const Expr *E);
355 PrimType classifyComplexElementType(QualType T) const {
356 assert(T->isAnyComplexType());
357
358 QualType ElemType = T->getAs<ComplexType>()->getElementType();
359
360 return *this->classify(ElemType);
361 }
362
363 PrimType classifyVectorElementType(QualType T) const {
364 assert(T->isVectorType());
365 return *this->classify(T->getAs<VectorType>()->getElementType());
366 }
367
368 bool emitComplexReal(const Expr *SubExpr);
369 bool emitComplexBoolCast(const Expr *E);
370 bool emitComplexComparison(const Expr *LHS, const Expr *RHS,
371 const BinaryOperator *E);
372 bool emitRecordDestruction(const Record *R, SourceInfo Loc);
373 bool emitDestruction(const Descriptor *Desc, SourceInfo Loc);
374 bool emitDummyPtr(const DeclTy &D, const Expr *E);
375 unsigned collectBaseOffset(const QualType BaseType,
376 const QualType DerivedType);
377 bool emitLambdaStaticInvokerBody(const CXXMethodDecl *MD);
378 bool emitBuiltinBitCast(const CastExpr *E);
379 bool compileConstructor(const CXXConstructorDecl *Ctor);
380 bool compileDestructor(const CXXDestructorDecl *Dtor);
381
382 bool checkLiteralType(const Expr *E);
383
384protected:
385 /// Variable to storage mapping.
386 llvm::DenseMap<const ValueDecl *, Scope::Local> Locals;
387
388 /// OpaqueValueExpr to location mapping.
389 llvm::DenseMap<const OpaqueValueExpr *, unsigned> OpaqueExprs;
390
391 /// Current scope.
393
394 /// Current argument index. Needed to emit ArrayInitIndexExpr.
395 std::optional<uint64_t> ArrayIndex;
396
397 /// DefaultInit- or DefaultArgExpr, needed for SourceLocExpr.
398 const Expr *SourceLocDefaultExpr = nullptr;
399
400 /// Flag indicating if return value is to be discarded.
401 bool DiscardResult = false;
402
403 bool InStmtExpr = false;
404
405 /// Flag inidicating if we're initializing an already created
406 /// variable. This is set in visitInitializer().
407 bool Initializing = false;
408 const ValueDecl *InitializingDecl = nullptr;
409
411 bool InitStackActive = false;
412
413 /// Type of the expression returned by the function.
414 std::optional<PrimType> ReturnType;
415
416 /// Switch case mapping.
418
419 /// Scope to cleanup until when we see a break statement.
421 /// Point to break to.
423 /// Scope to cleanup until when we see a continue statement.
425 /// Point to continue to.
427 /// Default case label.
429};
430
431extern template class Compiler<ByteCodeEmitter>;
432extern template class Compiler<EvalEmitter>;
433
434/// Scope chain managing the variable lifetimes.
435template <class Emitter> class VariableScope {
436public:
438 : Ctx(Ctx), Parent(Ctx->VarScope), ValDecl(VD) {
439 Ctx->VarScope = this;
440 }
441
442 virtual ~VariableScope() { Ctx->VarScope = this->Parent; }
443
444 void add(const Scope::Local &Local, bool IsExtended) {
445 if (IsExtended)
446 this->addExtended(Local);
447 else
448 this->addLocal(Local);
449 }
450
451 virtual void addLocal(const Scope::Local &Local) {
452 if (this->Parent)
453 this->Parent->addLocal(Local);
454 }
455
456 virtual void addExtended(const Scope::Local &Local) {
457 if (this->Parent)
458 this->Parent->addExtended(Local);
459 }
460
461 void addExtended(const Scope::Local &Local, const ValueDecl *ExtendingDecl) {
462 // Walk up the chain of scopes until we find the one for ExtendingDecl.
463 // If there is no such scope, attach it to the parent one.
464 VariableScope *P = this;
465 while (P) {
466 if (P->ValDecl == ExtendingDecl) {
467 P->addLocal(Local);
468 return;
469 }
470 P = P->Parent;
471 if (!P)
472 break;
473 }
474
475 // Use the parent scope.
476 if (this->Parent)
477 this->Parent->addLocal(Local);
478 else
479 this->addLocal(Local);
480 }
481
482 virtual void emitDestruction() {}
483 virtual bool emitDestructors(const Expr *E = nullptr) { return true; }
484 virtual bool destroyLocals(const Expr *E = nullptr) { return true; }
485 VariableScope *getParent() const { return Parent; }
486
487protected:
488 /// Compiler instance.
490 /// Link to the parent scope.
492 const ValueDecl *ValDecl = nullptr;
493};
494
495/// Generic scope for local variables.
496template <class Emitter> class LocalScope : public VariableScope<Emitter> {
497public:
500 : VariableScope<Emitter>(Ctx, VD) {}
501
502 /// Emit a Destroy op for this scope.
503 ~LocalScope() override {
504 if (!Idx)
505 return;
506 this->Ctx->emitDestroy(*Idx, SourceInfo{});
507 removeStoredOpaqueValues();
508 }
509
510 /// Overriden to support explicit destruction.
511 void emitDestruction() override {
512 if (!Idx)
513 return;
514
515 this->emitDestructors();
516 this->Ctx->emitDestroy(*Idx, SourceInfo{});
517 }
518
519 /// Explicit destruction of local variables.
520 bool destroyLocals(const Expr *E = nullptr) override {
521 if (!Idx)
522 return true;
523
524 bool Success = this->emitDestructors(E);
525 this->Ctx->emitDestroy(*Idx, E);
526 this->Idx = std::nullopt;
527 return Success;
528 }
529
530 void addLocal(const Scope::Local &Local) override {
531 if (!Idx) {
532 Idx = this->Ctx->Descriptors.size();
533 this->Ctx->Descriptors.emplace_back();
534 this->Ctx->emitInitScope(*Idx, {});
535 }
536
537 this->Ctx->Descriptors[*Idx].emplace_back(Local);
538 }
539
540 bool emitDestructors(const Expr *E = nullptr) override {
541 if (!Idx)
542 return true;
543 // Emit destructor calls for local variables of record
544 // type with a destructor.
545 for (Scope::Local &Local : llvm::reverse(this->Ctx->Descriptors[*Idx])) {
546 if (!Local.Desc->isPrimitive() && !Local.Desc->isPrimitiveArray()) {
547 if (!this->Ctx->emitGetPtrLocal(Local.Offset, E))
548 return false;
549
550 if (!this->Ctx->emitDestruction(Local.Desc, Local.Desc->getLoc()))
551 return false;
552
553 if (!this->Ctx->emitPopPtr(E))
554 return false;
555 removeIfStoredOpaqueValue(Local);
556 }
557 }
558 return true;
559 }
560
562 if (!Idx)
563 return;
564
565 for (const Scope::Local &Local : this->Ctx->Descriptors[*Idx]) {
566 removeIfStoredOpaqueValue(Local);
567 }
568 }
569
571 if (const auto *OVE =
572 llvm::dyn_cast_if_present<OpaqueValueExpr>(Local.Desc->asExpr())) {
573 if (auto It = this->Ctx->OpaqueExprs.find(OVE);
574 It != this->Ctx->OpaqueExprs.end())
575 this->Ctx->OpaqueExprs.erase(It);
576 };
577 }
578
579 /// Index of the scope in the chain.
580 std::optional<unsigned> Idx;
581};
582
583/// Scope for storage declared in a compound statement.
584template <class Emitter> class BlockScope final : public LocalScope<Emitter> {
585public:
587
588 void addExtended(const Scope::Local &Local) override {
589 // If we to this point, just add the variable as a normal local
590 // variable. It will be destroyed at the end of the block just
591 // like all others.
592 this->addLocal(Local);
593 }
594};
595
596template <class Emitter> class ArrayIndexScope final {
597public:
598 ArrayIndexScope(Compiler<Emitter> *Ctx, uint64_t Index) : Ctx(Ctx) {
599 OldArrayIndex = Ctx->ArrayIndex;
600 Ctx->ArrayIndex = Index;
601 }
602
603 ~ArrayIndexScope() { Ctx->ArrayIndex = OldArrayIndex; }
604
605private:
607 std::optional<uint64_t> OldArrayIndex;
608};
609
610template <class Emitter> class SourceLocScope final {
611public:
612 SourceLocScope(Compiler<Emitter> *Ctx, const Expr *DefaultExpr) : Ctx(Ctx) {
613 assert(DefaultExpr);
614 // We only switch if the current SourceLocDefaultExpr is null.
615 if (!Ctx->SourceLocDefaultExpr) {
616 Enabled = true;
617 Ctx->SourceLocDefaultExpr = DefaultExpr;
618 }
619 }
620
622 if (Enabled)
623 Ctx->SourceLocDefaultExpr = nullptr;
624 }
625
626private:
628 bool Enabled = false;
629};
630
631template <class Emitter> class InitLinkScope final {
632public:
634 Ctx->InitStack.push_back(std::move(Link));
635 }
636
637 ~InitLinkScope() { this->Ctx->InitStack.pop_back(); }
638
639private:
641};
642
643template <class Emitter> class InitStackScope final {
644public:
646 : Ctx(Ctx), OldValue(Ctx->InitStackActive) {
647 Ctx->InitStackActive = Active;
648 }
649
650 ~InitStackScope() { this->Ctx->InitStackActive = OldValue; }
651
652private:
654 bool OldValue;
655};
656
657} // namespace interp
658} // namespace clang
659
660#endif
NodeId Parent
Definition: ASTDiff.cpp:191
StringRef P
const Decl * D
Expr * E
llvm::MachO::Record Record
Definition: MachO.h:31
SourceLocation Loc
Definition: SemaObjC.cpp:759
__device__ __2f16 b
#define bool
Definition: amdgpuintrin.h:20
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:4224
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:4421
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition: Expr.h:5805
Represents a loop initializing the elements of an array.
Definition: Expr.h:5752
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2718
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Definition: ExprCXX.h:2853
Represents an attribute applied to a statement.
Definition: Stmt.h:2107
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3909
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:6414
BreakStmt - This represents a break.
Definition: Stmt.h:3007
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1491
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:720
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1546
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1268
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1375
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition: ExprCXX.h:2498
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:1737
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition: ExprCXX.h:2241
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:4126
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:765
Represents a list-initialization with parenthesis.
Definition: ExprCXX.h:4960
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:523
A rewritten comparison expression that was originally written using operator syntax.
Definition: ExprCXX.h:283
An expression "T()" which creates an rvalue of a non-class type T.
Definition: ExprCXX.h:2182
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:797
Represents the this expression in C++.
Definition: ExprCXX.h:1152
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:1206
CXXTryStmt - A C++ try block, including all handlers.
Definition: StmtCXX.h:69
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:1066
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2874
CaseStmt - Represent a case statement.
Definition: Stmt.h:1828
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3547
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition: Expr.h:4641
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:4171
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:3477
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1628
Represents the specialization of a concept - evaluates to a prvalue of type bool.
Definition: ExprConcepts.h:42
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
Definition: StmtVisitor.h:195
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition: Expr.h:1077
ContinueStmt - This represents a continue.
Definition: Stmt.h:2977
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:4582
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1265
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition: Stmt.h:1519
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
DoStmt - This represents a 'do/while' stmt.
Definition: Stmt.h:2752
Represents a reference to #emded data.
Definition: Expr.h:4916
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition: ExprCXX.h:3474
This represents one expression.
Definition: Expr.h:110
An expression trait intrinsic.
Definition: ExprCXX.h:2924
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition: Expr.h:6354
RoundingMode getRoundingMode() const
Definition: LangOptions.h:912
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition: Stmt.h:2808
Represents a function declaration or definition.
Definition: Decl.h:1935
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition: Expr.h:4716
Represents a C11 generic selection.
Definition: Expr.h:5966
IfStmt - This represents an if/then/else.
Definition: Stmt.h:2165
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
Definition: Expr.h:1717
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:5841
Describes an C or C++ initializer list.
Definition: Expr.h:5088
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1954
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4734
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:3236
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:87
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:127
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:410
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition: ExprObjC.h:51
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
Definition: Expr.h:2519
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition: Expr.h:1173
ParenExpr - This represents a parenthesized expression, e.g.
Definition: Expr.h:2170
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1991
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:6546
A (possibly-)qualified type.
Definition: Type.h:929
Represents a struct/union/class.
Definition: Decl.h:4148
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:6072
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
Definition: Expr.h:7258
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:502
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition: Stmt.h:3046
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:4514
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:4258
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Definition: Expr.h:4810
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:4466
Stmt - This represents one statement.
Definition: Stmt.h:84
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1778
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:4490
SwitchStmt - This represents a 'switch' stmt.
Definition: Stmt.h:2415
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2768
bool isAnyComplexType() const
Definition: Type.h:8294
bool isVectorType() const
Definition: Type.h:8298
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:8731
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition: Expr.h:2622
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition: Expr.h:2232
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:671
Represents a variable declaration or definition.
Definition: Decl.h:882
WhileStmt - This represents a 'while' stmt.
Definition: Stmt.h:2611
ArrayIndexScope(Compiler< Emitter > *Ctx, uint64_t Index)
Definition: Compiler.h:598
Scope for storage declared in a compound statement.
Definition: Compiler.h:584
BlockScope(Compiler< Emitter > *Ctx)
Definition: Compiler.h:586
void addExtended(const Scope::Local &Local) override
Definition: Compiler.h:588
Compilation context for expressions.
Definition: Compiler.h:104
std::optional< PrimType > classify(const Expr *E) const
Definition: Compiler.h:248
llvm::SmallVector< InitLink > InitStack
Definition: Compiler.h:410
OptLabelTy BreakLabel
Point to break to.
Definition: Compiler.h:422
bool VisitArrayInitIndexExpr(const ArrayInitIndexExpr *E)
Definition: Compiler.cpp:2196
bool VisitCXXDeleteExpr(const CXXDeleteExpr *E)
Definition: Compiler.cpp:3400
bool VisitOffsetOfExpr(const OffsetOfExpr *E)
Definition: Compiler.cpp:3119
bool visitContinueStmt(const ContinueStmt *S)
Definition: Compiler.cpp:5200
bool VisitCharacterLiteral(const CharacterLiteral *E)
Definition: Compiler.cpp:2413
PrimType classifyPrim(const Expr *E) const
Classifies a known primitive expression.
Definition: Compiler.h:263
bool VisitCXXParenListInitExpr(const CXXParenListInitExpr *E)
Definition: Compiler.cpp:1986
bool VisitConceptSpecializationExpr(const ConceptSpecializationExpr *E)
Definition: Compiler.cpp:3478
bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E)
Definition: Compiler.cpp:2746
bool visitBool(const Expr *E)
Visits an expression and converts it to a boolean.
Definition: Compiler.cpp:3802
bool VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *E)
Definition: Compiler.cpp:4757
bool visitDeclAndReturn(const VarDecl *VD, bool ConstantContext) override
Toplevel visitDeclAndReturn().
Definition: Compiler.cpp:4245
PrimType classifyPrim(QualType Ty) const
Classifies a known primitive type.
Definition: Compiler.h:256
bool VisitTypeTraitExpr(const TypeTraitExpr *E)
Definition: Compiler.cpp:2811
bool VisitLambdaExpr(const LambdaExpr *E)
Definition: Compiler.cpp:2827
bool VisitMemberExpr(const MemberExpr *E)
Definition: Compiler.cpp:2140
llvm::DenseMap< const OpaqueValueExpr *, unsigned > OpaqueExprs
OpaqueValueExpr to location mapping.
Definition: Compiler.h:389
bool VisitBinaryOperator(const BinaryOperator *E)
Definition: Compiler.cpp:789
bool visitAttributedStmt(const AttributedStmt *S)
Definition: Compiler.cpp:5295
bool VisitPackIndexingExpr(const PackIndexingExpr *E)
Definition: Compiler.cpp:3517
bool VisitArraySubscriptExpr(const ArraySubscriptExpr *E)
Definition: Compiler.cpp:1688
bool VisitCallExpr(const CallExpr *E)
Definition: Compiler.cpp:4556
std::optional< uint64_t > ArrayIndex
Current argument index. Needed to emit ArrayInitIndexExpr.
Definition: Compiler.h:395
bool VisitPseudoObjectExpr(const PseudoObjectExpr *E)
Definition: Compiler.cpp:3493
bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E)
Definition: Compiler.cpp:2887
const Function * getFunction(const FunctionDecl *FD)
Returns a function for the given FunctionDecl.
Definition: Compiler.cpp:4160
void emitCleanup()
Emits scope cleanup instructions.
Definition: Compiler.cpp:6171
bool VisitFixedPointBinOp(const BinaryOperator *E)
Definition: Compiler.cpp:1518
bool VisitCastExpr(const CastExpr *E)
Definition: Compiler.cpp:191
bool VisitObjCEncodeExpr(const ObjCEncodeExpr *E)
Definition: Compiler.cpp:2378
bool VisitFixedPointUnaryOperator(const UnaryOperator *E)
Definition: Compiler.cpp:1605
bool VisitComplexUnaryOperator(const UnaryOperator *E)
Definition: Compiler.cpp:5821
std::optional< PrimType > classify(QualType Ty) const
Definition: Compiler.h:251
llvm::DenseMap< const SwitchCase *, LabelTy > CaseMap
Definition: Compiler.h:110
bool visitDeclStmt(const DeclStmt *DS)
Definition: Compiler.cpp:4898
bool VisitBlockExpr(const BlockExpr *E)
Definition: Compiler.cpp:3416
bool visitAPValue(const APValue &Val, PrimType ValType, const Expr *E)
Visit an APValue.
Definition: Compiler.cpp:4417
bool VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *E)
Definition: Compiler.cpp:3154
bool VisitLogicalBinOp(const BinaryOperator *E)
Definition: Compiler.cpp:1050
bool visitCompoundStmt(const CompoundStmt *S)
Definition: Compiler.cpp:4889
std::optional< PrimType > ReturnType
Type of the expression returned by the function.
Definition: Compiler.h:414
Context & Ctx
Current compilation context.
Definition: Compiler.h:113
bool visitDeclRef(const ValueDecl *D, const Expr *E)
Visit the given decl as if we have a reference to it.
Definition: Compiler.cpp:6035
bool visitBreakStmt(const BreakStmt *S)
Definition: Compiler.cpp:5189
bool visitExpr(const Expr *E, bool DestroyToplevelScope) override
Definition: Compiler.cpp:4165
bool visitForStmt(const ForStmt *S)
Definition: Compiler.cpp:5082
bool VisitDeclRefExpr(const DeclRefExpr *E)
Definition: Compiler.cpp:6166
bool VisitOpaqueValueExpr(const OpaqueValueExpr *E)
Definition: Compiler.cpp:2235
bool VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E)
Definition: Compiler.cpp:2205
OptLabelTy DefaultLabel
Default case label.
Definition: Compiler.h:428
bool VisitStmtExpr(const StmtExpr *E)
Definition: Compiler.cpp:3732
std::optional< unsigned > allocateLocal(DeclTy &&Decl, QualType Ty=QualType(), const ValueDecl *ExtendingDecl=nullptr)
Allocates a space storing a local given its type.
Definition: Compiler.cpp:4079
bool VisitFixedPointLiteral(const FixedPointLiteral *E)
Definition: Compiler.cpp:771
bool VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E)
Definition: Compiler.cpp:4776
VariableScope< Emitter > * VarScope
Current scope.
Definition: Compiler.h:392
VariableScope< Emitter > * ContinueVarScope
Scope to cleanup until when we see a continue statement.
Definition: Compiler.h:424
bool VisitCXXNewExpr(const CXXNewExpr *E)
Definition: Compiler.cpp:3268
const ValueDecl * InitializingDecl
Definition: Compiler.h:408
bool VisitCompoundAssignOperator(const CompoundAssignOperator *E)
Definition: Compiler.cpp:2530
bool visitArrayElemInit(unsigned ElemIndex, const Expr *Init)
Pointer to the array(not the element!) must be on the stack when calling this.
Definition: Compiler.cpp:1959
bool delegate(const Expr *E)
Just pass evaluation on to E.
Definition: Compiler.cpp:3760
bool discard(const Expr *E)
Evaluates an expression for side effects and discards the result.
Definition: Compiler.cpp:3754
bool VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *E)
Definition: Compiler.cpp:4764
CaseMap CaseLabels
Switch case mapping.
Definition: Compiler.h:417
Record * getRecord(QualType Ty)
Returns a record from a record or pointer type.
Definition: Compiler.cpp:4148
bool visit(const Expr *E)
Evaluates an expression and places the result on the stack.
Definition: Compiler.cpp:3767
const RecordType * getRecordTy(QualType Ty)
Returns a record type from a record or pointer type.
Definition: Compiler.cpp:4142
bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E)
Definition: Compiler.cpp:3693
bool visitInitList(ArrayRef< const Expr * > Inits, const Expr *ArrayFiller, const Expr *E)
Definition: Compiler.cpp:1718
bool VisitSizeOfPackExpr(const SizeOfPackExpr *E)
Definition: Compiler.cpp:3213
bool VisitPredefinedExpr(const PredefinedExpr *E)
Definition: Compiler.cpp:2866
bool VisitSourceLocExpr(const SourceLocExpr *E)
Definition: Compiler.cpp:3063
Compiler(Context &Ctx, Program &P, Tys &&...Args)
Initializes the compiler and the backend emitter.
Definition: Compiler.h:120
bool VisitExtVectorElementExpr(const ExtVectorElementExpr *E)
Definition: Compiler.cpp:3618
bool VisitObjCStringLiteral(const ObjCStringLiteral *E)
Definition: Compiler.cpp:2371
bool VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *E)
Definition: Compiler.cpp:2820
bool visitInitializer(const Expr *E)
Compiles an initializer.
Definition: Compiler.cpp:3794
const Expr * SourceLocDefaultExpr
DefaultInit- or DefaultArgExpr, needed for SourceLocExpr.
Definition: Compiler.h:398
bool VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *E)
Definition: Compiler.cpp:2740
bool VisitPointerArithBinOp(const BinaryOperator *E)
Perform addition/subtraction of a pointer and an integer or subtraction of two pointers.
Definition: Compiler.cpp:973
bool VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *E)
Definition: Compiler.cpp:3229
bool visitDefaultStmt(const DefaultStmt *S)
Definition: Compiler.cpp:5289
typename Emitter::LabelTy LabelTy
Definition: Compiler.h:107
VarCreationState visitDecl(const VarDecl *VD)
Definition: Compiler.cpp:4217
bool visitStmt(const Stmt *S)
Definition: Compiler.cpp:4839
bool VisitExpressionTraitExpr(const ExpressionTraitExpr *E)
Definition: Compiler.cpp:3430
bool visitAPValueInitializer(const APValue &Val, const Expr *E)
Definition: Compiler.cpp:4444
bool VisitVectorUnaryOperator(const UnaryOperator *E)
Definition: Compiler.cpp:5928
bool VisitCXXConstructExpr(const CXXConstructExpr *E)
Definition: Compiler.cpp:2943
bool VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E)
Definition: Compiler.cpp:4784
bool VisitObjCBoxedExpr(const ObjCBoxedExpr *E)
Definition: Compiler.cpp:3680
bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E)
Definition: Compiler.cpp:3237
bool VisitRecoveryExpr(const RecoveryExpr *E)
Definition: Compiler.cpp:3522
bool VisitRequiresExpr(const RequiresExpr *E)
Definition: Compiler.cpp:3470
bool Initializing
Flag inidicating if we're initializing an already created variable.
Definition: Compiler.h:407
bool visitReturnStmt(const ReturnStmt *RS)
Definition: Compiler.cpp:4915
bool VisitCXXThrowExpr(const CXXThrowExpr *E)
Definition: Compiler.cpp:2879
bool VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E)
Definition: Compiler.cpp:1992
bool VisitChooseExpr(const ChooseExpr *E)
Definition: Compiler.cpp:3224
bool visitFunc(const FunctionDecl *F) override
Definition: Compiler.cpp:5564
bool visitCXXForRangeStmt(const CXXForRangeStmt *S)
Definition: Compiler.cpp:5133
bool visitCaseStmt(const CaseStmt *S)
Definition: Compiler.cpp:5283
bool VisitComplexBinOp(const BinaryOperator *E)
Definition: Compiler.cpp:1111
llvm::DenseMap< const ValueDecl *, Scope::Local > Locals
Variable to storage mapping.
Definition: Compiler.h:386
bool VisitAbstractConditionalOperator(const AbstractConditionalOperator *E)
Definition: Compiler.cpp:2271
bool VisitBuiltinCallExpr(const CallExpr *E, unsigned BuiltinID)
Definition: Compiler.cpp:4507
OptLabelTy ContinueLabel
Point to continue to.
Definition: Compiler.h:426
bool VisitImplicitValueInitExpr(const ImplicitValueInitExpr *E)
Definition: Compiler.cpp:1624
typename Emitter::AddrTy AddrTy
Definition: Compiler.h:108
bool VisitCXXRewrittenBinaryOperator(const CXXRewrittenBinaryOperator *E)
Definition: Compiler.cpp:3487
bool VisitUnaryOperator(const UnaryOperator *E)
Definition: Compiler.cpp:5590
bool VisitFloatCompoundAssignOperator(const CompoundAssignOperator *E)
Definition: Compiler.cpp:2420
bool VisitGenericSelectionExpr(const GenericSelectionExpr *E)
Definition: Compiler.cpp:3218
bool visitDoStmt(const DoStmt *S)
Definition: Compiler.cpp:5049
bool VisitIntegerLiteral(const IntegerLiteral *E)
Definition: Compiler.cpp:733
bool VisitInitListExpr(const InitListExpr *E)
Definition: Compiler.cpp:1981
bool VisitVectorBinOp(const BinaryOperator *E)
Definition: Compiler.cpp:1334
bool VisitStringLiteral(const StringLiteral *E)
Definition: Compiler.cpp:2314
bool VisitParenExpr(const ParenExpr *E)
Definition: Compiler.cpp:784
bool VisitCXXNoexceptExpr(const CXXNoexceptExpr *E)
Definition: Compiler.cpp:2934
bool VisitShuffleVectorExpr(const ShuffleVectorExpr *E)
Definition: Compiler.cpp:3575
bool VisitPointerCompoundAssignOperator(const CompoundAssignOperator *E)
Definition: Compiler.cpp:2493
VariableScope< Emitter > * BreakVarScope
Scope to cleanup until when we see a break statement.
Definition: Compiler.h:420
std::optional< LabelTy > OptLabelTy
Definition: Compiler.h:109
bool DiscardResult
Flag indicating if return value is to be discarded.
Definition: Compiler.h:401
bool VisitEmbedExpr(const EmbedExpr *E)
Definition: Compiler.cpp:2014
bool VisitConvertVectorExpr(const ConvertVectorExpr *E)
Definition: Compiler.cpp:3537
bool VisitCXXThisExpr(const CXXThisExpr *E)
Definition: Compiler.cpp:4805
bool VisitConstantExpr(const ConstantExpr *E)
Definition: Compiler.cpp:1998
unsigned allocateTemporary(const Expr *E)
Definition: Compiler.cpp:4121
bool VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *E)
Definition: Compiler.cpp:2043
bool visitSwitchStmt(const SwitchStmt *S)
Definition: Compiler.cpp:5211
bool VisitCXXUuidofExpr(const CXXUuidofExpr *E)
Definition: Compiler.cpp:3436
unsigned allocateLocalPrimitive(DeclTy &&Decl, PrimType Ty, bool IsConst, bool IsExtended=false)
Creates a local primitive value.
Definition: Compiler.cpp:4054
bool VisitExprWithCleanups(const ExprWithCleanups *E)
Definition: Compiler.cpp:2653
bool visitWhileStmt(const WhileStmt *S)
Definition: Compiler.cpp:5013
bool visitIfStmt(const IfStmt *IS)
Definition: Compiler.cpp:4949
bool VisitAddrLabelExpr(const AddrLabelExpr *E)
Definition: Compiler.cpp:3527
bool VisitFloatingLiteral(const FloatingLiteral *E)
Definition: Compiler.cpp:741
Program & P
Program to link to.
Definition: Compiler.h:115
bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E)
Definition: Compiler.cpp:2661
bool VisitGNUNullExpr(const GNUNullExpr *E)
Definition: Compiler.cpp:4794
bool VisitImaginaryLiteral(const ImaginaryLiteral *E)
Definition: Compiler.cpp:749
bool VisitSYCLUniqueStableNameExpr(const SYCLUniqueStableNameExpr *E)
Definition: Compiler.cpp:2389
VarCreationState visitVarDecl(const VarDecl *VD, bool Toplevel=false)
Creates and initializes a variable from the given decl.
Definition: Compiler.cpp:4306
bool visitCXXTryStmt(const CXXTryStmt *S)
Definition: Compiler.cpp:5326
Holds all information required to evaluate constexpr code in a module.
Definition: Context.h:40
const LangOptions & getLangOpts() const
Returns the language options.
Definition: Context.cpp:133
std::optional< PrimType > classify(QualType T) const
Classifies a type.
Definition: Context.cpp:135
Scope used to handle temporaries in toplevel variable declarations.
Definition: Compiler.cpp:29
Bytecode function.
Definition: Function.h:81
InitLinkScope(Compiler< Emitter > *Ctx, InitLink &&Link)
Definition: Compiler.h:633
InitStackScope(Compiler< Emitter > *Ctx, bool Active)
Definition: Compiler.h:645
Scope managing label targets.
Definition: Compiler.cpp:100
Generic scope for local variables.
Definition: Compiler.h:496
LocalScope(Compiler< Emitter > *Ctx)
Definition: Compiler.h:498
~LocalScope() override
Emit a Destroy op for this scope.
Definition: Compiler.h:503
bool destroyLocals(const Expr *E=nullptr) override
Explicit destruction of local variables.
Definition: Compiler.h:520
LocalScope(Compiler< Emitter > *Ctx, const ValueDecl *VD)
Definition: Compiler.h:499
bool emitDestructors(const Expr *E=nullptr) override
Definition: Compiler.h:540
void emitDestruction() override
Overriden to support explicit destruction.
Definition: Compiler.h:511
void removeIfStoredOpaqueValue(const Scope::Local &Local)
Definition: Compiler.h:570
void addLocal(const Scope::Local &Local) override
Definition: Compiler.h:530
std::optional< unsigned > Idx
Index of the scope in the chain.
Definition: Compiler.h:580
Sets the context for break/continue statements.
Definition: Compiler.cpp:111
Scope used to handle initialization methods.
Definition: Compiler.cpp:53
The program contains and links the bytecode for all functions.
Definition: Program.h:39
Structure/Class descriptor.
Definition: Record.h:25
Describes the statement/declaration an opcode was generated from.
Definition: Source.h:77
SourceLocScope(Compiler< Emitter > *Ctx, const Expr *DefaultExpr)
Definition: Compiler.h:612
Scope chain managing the variable lifetimes.
Definition: Compiler.h:435
virtual void addExtended(const Scope::Local &Local)
Definition: Compiler.h:456
void addExtended(const Scope::Local &Local, const ValueDecl *ExtendingDecl)
Definition: Compiler.h:461
void add(const Scope::Local &Local, bool IsExtended)
Definition: Compiler.h:444
Compiler< Emitter > * Ctx
Compiler instance.
Definition: Compiler.h:489
virtual bool emitDestructors(const Expr *E=nullptr)
Definition: Compiler.h:483
virtual bool destroyLocals(const Expr *E=nullptr)
Definition: Compiler.h:484
VariableScope * Parent
Link to the parent scope.
Definition: Compiler.h:491
virtual void addLocal(const Scope::Local &Local)
Definition: Compiler.h:451
VariableScope * getParent() const
Definition: Compiler.h:485
VariableScope(Compiler< Emitter > *Ctx, const ValueDecl *VD)
Definition: Compiler.h:437
virtual void emitDestruction()
Definition: Compiler.h:482
Defines the clang::TargetInfo interface.
PrimType
Enumeration of the primitive types of the VM.
Definition: PrimType.h:34
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
Definition: Descriptor.h:29
The JSON file list parser is used to communicate input to InstallAPI.
@ Link
'link' clause, allowed on 'declare' construct.
const FunctionProtoType * T
@ Success
Template argument deduction was successful.
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:91
static VarCreationState NotCreated()
Definition: Compiler.h:95
std::optional< bool > S
Definition: Compiler.h:92