clang 22.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,
55 K_InitList = 7
56 };
57
58 static InitLink This() { return InitLink{K_This}; }
59 static InitLink InitList() { return InitLink{K_InitList}; }
60 static InitLink RVO() { return InitLink{K_RVO}; }
61 static InitLink Field(unsigned Offset) {
62 InitLink IL{K_Field};
63 IL.Offset = Offset;
64 return IL;
65 }
66 static InitLink Temp(unsigned Offset) {
67 InitLink IL{K_Temp};
68 IL.Offset = Offset;
69 return IL;
70 }
71 static InitLink Decl(const ValueDecl *D) {
72 InitLink IL{K_Decl};
73 IL.D = D;
74 return IL;
75 }
76 static InitLink Elem(unsigned Index) {
77 InitLink IL{K_Elem};
78 IL.Offset = Index;
79 return IL;
80 }
81
82 InitLink(uint8_t Kind) : Kind(Kind) {}
83 template <class Emitter>
84 bool emit(Compiler<Emitter> *Ctx, const Expr *E) const;
85
86 uint32_t Kind;
87 union {
88 unsigned Offset;
89 const ValueDecl *D;
90 };
91};
92
93/// State encapsulating if a the variable creation has been successful,
94/// unsuccessful, or no variable has been created at all.
96 std::optional<bool> S = std::nullopt;
97 VarCreationState() = default;
98 VarCreationState(bool b) : S(b) {}
100
101 operator bool() const { return S && *S; }
102 bool notCreated() const { return !S; }
103};
104
105enum class ScopeKind { Call, Block };
106
107/// Compilation context for expressions.
108template <class Emitter>
109class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
110 public Emitter {
111protected:
112 // Aliases for types defined in the emitter.
113 using LabelTy = typename Emitter::LabelTy;
114 using AddrTy = typename Emitter::AddrTy;
115 using OptLabelTy = std::optional<LabelTy>;
116 using CaseMap = llvm::DenseMap<const SwitchCase *, LabelTy>;
117
118 /// Current compilation context.
120 /// Program to link to.
122
123public:
124 /// Initializes the compiler and the backend emitter.
125 template <typename... Tys>
126 Compiler(Context &Ctx, Program &P, Tys &&...Args)
127 : Emitter(Ctx, P, Args...), Ctx(Ctx), P(P) {}
128
129 // Expressions.
130 bool VisitCastExpr(const CastExpr *E);
136 bool VisitParenExpr(const ParenExpr *E);
141 bool VisitVectorBinOp(const BinaryOperator *E);
145 bool VisitCallExpr(const CallExpr *E);
146 bool VisitBuiltinCallExpr(const CallExpr *E, unsigned BuiltinID);
150 bool VisitGNUNullExpr(const GNUNullExpr *E);
151 bool VisitCXXThisExpr(const CXXThisExpr *E);
155 bool VisitDeclRefExpr(const DeclRefExpr *E);
159 bool VisitInitListExpr(const InitListExpr *E);
161 bool VisitConstantExpr(const ConstantExpr *E);
163 bool VisitMemberExpr(const MemberExpr *E);
182 bool VisitLambdaExpr(const LambdaExpr *E);
184 bool VisitCXXThrowExpr(const CXXThrowExpr *E);
190 bool VisitOffsetOfExpr(const OffsetOfExpr *E);
194 bool VisitChooseExpr(const ChooseExpr *E);
195 bool VisitEmbedExpr(const EmbedExpr *E);
200 bool VisitRequiresExpr(const RequiresExpr *E);
205 bool VisitRecoveryExpr(const RecoveryExpr *E);
212 bool VisitStmtExpr(const StmtExpr *E);
213 bool VisitCXXNewExpr(const CXXNewExpr *E);
215 bool VisitBlockExpr(const BlockExpr *E);
217
218 // Statements.
219 bool visitCompoundStmt(const CompoundStmt *S);
220 bool visitDeclStmt(const DeclStmt *DS, bool EvaluateConditionDecl = false);
221 bool visitReturnStmt(const ReturnStmt *RS);
222 bool visitIfStmt(const IfStmt *IS);
223 bool visitWhileStmt(const WhileStmt *S);
224 bool visitDoStmt(const DoStmt *S);
225 bool visitForStmt(const ForStmt *S);
227 bool visitBreakStmt(const BreakStmt *S);
228 bool visitContinueStmt(const ContinueStmt *S);
229 bool visitSwitchStmt(const SwitchStmt *S);
230 bool visitCaseStmt(const CaseStmt *S);
231 bool visitDefaultStmt(const DefaultStmt *S);
232 bool visitAttributedStmt(const AttributedStmt *S);
233 bool visitCXXTryStmt(const CXXTryStmt *S);
234
235protected:
236 bool visitStmt(const Stmt *S);
237 bool visitExpr(const Expr *E, bool DestroyToplevelScope) override;
238 bool visitFunc(const FunctionDecl *F) override;
239
240 bool visitDeclAndReturn(const VarDecl *VD, bool ConstantContext) override;
241
242protected:
243 /// Emits scope cleanup instructions.
244 void emitCleanup();
245
246 /// Returns a record type from a record or pointer type.
248
249 /// Returns a record from a record or pointer type.
251 Record *getRecord(const RecordDecl *RD);
252
253 /// Returns a function for the given FunctionDecl.
254 /// If the function does not exist yet, it is compiled.
255 const Function *getFunction(const FunctionDecl *FD);
256
257 OptPrimType classify(const Expr *E) const { return Ctx.classify(E); }
258 OptPrimType classify(QualType Ty) const { return Ctx.classify(Ty); }
259 bool canClassify(const Expr *E) const { return Ctx.canClassify(E); }
260 bool canClassify(QualType T) const { return Ctx.canClassify(T); }
261
262 /// Classifies a known primitive type.
264 if (auto T = classify(Ty)) {
265 return *T;
266 }
267 llvm_unreachable("not a primitive type");
268 }
269 /// Classifies a known primitive expression.
270 PrimType classifyPrim(const Expr *E) const {
271 if (auto T = classify(E))
272 return *T;
273 llvm_unreachable("not a primitive type");
274 }
275
276 /// Evaluates an expression and places the result on the stack. If the
277 /// expression is of composite type, a local variable will be created
278 /// and a pointer to said variable will be placed on the stack.
279 bool visit(const Expr *E) override;
280 /// Compiles an initializer. This is like visit() but it will never
281 /// create a variable and instead rely on a variable already having
282 /// been created. visitInitializer() then relies on a pointer to this
283 /// variable being on top of the stack.
284 bool visitInitializer(const Expr *E);
285 bool visitAsLValue(const Expr *E);
286 /// Evaluates an expression for side effects and discards the result.
287 bool discard(const Expr *E);
288 /// Just pass evaluation on to \p E. This leaves all the parsing flags
289 /// intact.
290 bool delegate(const Expr *E);
291 /// Creates and initializes a variable from the given decl.
292 VarCreationState visitVarDecl(const VarDecl *VD, bool Toplevel = false,
293 bool IsConstexprUnknown = false);
295 bool IsConstexprUnknown = false);
296 /// Visit an APValue.
297 bool visitAPValue(const APValue &Val, PrimType ValType, const Expr *E);
298 bool visitAPValueInitializer(const APValue &Val, const Expr *E, QualType T);
299 /// Visit the given decl as if we have a reference to it.
300 bool visitDeclRef(const ValueDecl *D, const Expr *E);
301
302 /// Visits an expression and converts it to a boolean.
303 bool visitBool(const Expr *E);
304
305 bool visitInitList(ArrayRef<const Expr *> Inits, const Expr *ArrayFiller,
306 const Expr *E);
307 bool visitArrayElemInit(unsigned ElemIndex, const Expr *Init,
308 OptPrimType InitT);
309 bool visitCallArgs(ArrayRef<const Expr *> Args, const FunctionDecl *FuncDecl,
310 bool Activate, bool IsOperatorCall);
311
312 /// Creates a local primitive value.
313 unsigned allocateLocalPrimitive(DeclTy &&Decl, PrimType Ty, bool IsConst,
314 const ValueDecl *ExtendingDecl = nullptr,
316 bool IsConstexprUnknown = false);
317
318 /// Allocates a space storing a local given its type.
320 const ValueDecl *ExtendingDecl = nullptr,
322 bool IsConstexprUnknown = false);
324
325private:
326 friend class VariableScope<Emitter>;
327 friend class LocalScope<Emitter>;
328 friend class DestructorScope<Emitter>;
329 friend class DeclScope<Emitter>;
330 friend class InitLinkScope<Emitter>;
331 friend class InitStackScope<Emitter>;
332 friend class OptionScope<Emitter>;
333 friend class ArrayIndexScope<Emitter>;
334 friend class SourceLocScope<Emitter>;
335 friend struct InitLink;
336 friend class LoopScope<Emitter>;
337 friend class LabelScope<Emitter>;
338 friend class SwitchScope<Emitter>;
339 friend class StmtExprScope<Emitter>;
340 friend class LocOverrideScope<Emitter>;
341
342 /// Emits a zero initializer.
343 bool visitZeroInitializer(PrimType T, QualType QT, const Expr *E);
344 bool visitZeroRecordInitializer(const Record *R, const Expr *E);
345 bool visitZeroArrayInitializer(QualType T, const Expr *E);
346 bool visitAssignment(const Expr *LHS, const Expr *RHS, const Expr *E);
347
348 /// Emits an APSInt constant.
349 bool emitConst(const llvm::APSInt &Value, PrimType Ty, const Expr *E);
350 bool emitConst(const llvm::APInt &Value, PrimType Ty, const Expr *E);
351 bool emitConst(const llvm::APSInt &Value, const Expr *E);
352 bool emitConst(const llvm::APInt &Value, const Expr *E) {
353 return emitConst(Value, classifyPrim(E), E);
354 }
355
356 /// Emits an integer constant.
357 template <typename T> bool emitConst(T Value, PrimType Ty, const Expr *E);
358 template <typename T> bool emitConst(T Value, const Expr *E);
359 bool emitBool(bool V, const Expr *E) override {
360 return this->emitConst(V, E);
361 }
362
363 llvm::RoundingMode getRoundingMode(const Expr *E) const {
364 FPOptions FPO = E->getFPFeaturesInEffect(Ctx.getLangOpts());
365
366 if (FPO.getRoundingMode() == llvm::RoundingMode::Dynamic)
367 return llvm::RoundingMode::NearestTiesToEven;
368
369 return FPO.getRoundingMode();
370 }
371
372 uint32_t getFPOptions(const Expr *E) const {
373 return E->getFPFeaturesInEffect(Ctx.getLangOpts()).getAsOpaqueInt();
374 }
375
376 bool emitPrimCast(PrimType FromT, PrimType ToT, QualType ToQT, const Expr *E);
377 PrimType classifyComplexElementType(QualType T) const {
378 assert(T->isAnyComplexType());
379
380 QualType ElemType = T->getAs<ComplexType>()->getElementType();
381
382 return *this->classify(ElemType);
383 }
384
385 PrimType classifyVectorElementType(QualType T) const {
386 assert(T->isVectorType());
387 return *this->classify(T->getAs<VectorType>()->getElementType());
388 }
389
390 bool emitComplexReal(const Expr *SubExpr);
391 bool emitComplexBoolCast(const Expr *E);
392 bool emitComplexComparison(const Expr *LHS, const Expr *RHS,
393 const BinaryOperator *E);
394 bool emitRecordDestruction(const Record *R, SourceInfo Loc);
395 bool emitDestruction(const Descriptor *Desc, SourceInfo Loc);
396 bool emitDummyPtr(const DeclTy &D, const Expr *E);
397 bool emitFloat(const APFloat &F, const Expr *E);
398 unsigned collectBaseOffset(const QualType BaseType,
399 const QualType DerivedType);
400 bool emitLambdaStaticInvokerBody(const CXXMethodDecl *MD);
401 bool emitBuiltinBitCast(const CastExpr *E);
402 bool compileConstructor(const CXXConstructorDecl *Ctor);
403 bool compileDestructor(const CXXDestructorDecl *Dtor);
404 bool compileUnionAssignmentOperator(const CXXMethodDecl *MD);
405
406 bool checkLiteralType(const Expr *E);
407 bool maybeEmitDeferredVarInit(const VarDecl *VD);
408
409 bool refersToUnion(const Expr *E);
410
411protected:
412 /// Variable to storage mapping.
413 llvm::DenseMap<const ValueDecl *, Scope::Local> Locals;
414
415 /// OpaqueValueExpr to location mapping.
416 llvm::DenseMap<const OpaqueValueExpr *, unsigned> OpaqueExprs;
417
418 /// Current scope.
420
421 /// Current argument index. Needed to emit ArrayInitIndexExpr.
422 std::optional<uint64_t> ArrayIndex;
423
424 /// DefaultInit- or DefaultArgExpr, needed for SourceLocExpr.
425 const Expr *SourceLocDefaultExpr = nullptr;
426
427 /// Flag indicating if return value is to be discarded.
428 bool DiscardResult = false;
429
430 bool InStmtExpr = false;
431 bool ToLValue = false;
432
433 /// Flag inidicating if we're initializing an already created
434 /// variable. This is set in visitInitializer().
435 bool Initializing = false;
436 const ValueDecl *InitializingDecl = nullptr;
437
439 bool InitStackActive = false;
440
441 /// Type of the expression returned by the function.
443
444 /// Switch case mapping.
446
447 /// Scope to cleanup until when we see a break statement.
449 /// Point to break to.
451 /// Scope to cleanup until when we see a continue statement.
453 /// Point to continue to.
455 /// Default case label.
457
459};
460
461extern template class Compiler<ByteCodeEmitter>;
462extern template class Compiler<EvalEmitter>;
463
464/// Scope chain managing the variable lifetimes.
465template <class Emitter> class VariableScope {
466public:
469 : Ctx(Ctx), Parent(Ctx->VarScope), ValDecl(VD), Kind(Kind) {
470 Ctx->VarScope = this;
471 }
472
473 virtual ~VariableScope() { Ctx->VarScope = this->Parent; }
474
475 virtual void addLocal(const Scope::Local &Local) {
476 llvm_unreachable("Shouldn't be called");
477 }
478
479 void addExtended(const Scope::Local &Local, const ValueDecl *ExtendingDecl) {
480 // Walk up the chain of scopes until we find the one for ExtendingDecl.
481 // If there is no such scope, attach it to the parent one.
482 VariableScope *P = this;
483 while (P) {
484 if (P->ValDecl == ExtendingDecl) {
485 P->addLocal(Local);
486 return;
487 }
488 P = P->Parent;
489 if (!P)
490 break;
491 }
492
493 // Use the parent scope.
494 if (this->Parent)
495 this->Parent->addLocal(Local);
496 else
497 this->addLocal(Local);
498 }
499
500 /// Like addExtended, but adds to the nearest scope of the given kind.
502 VariableScope *P = this;
503 while (P) {
504 if (P->Kind == Kind) {
505 P->addLocal(Local);
506 return;
507 }
508 P = P->Parent;
509 if (!P)
510 break;
511 }
512
513 // Add to this scope.
514 this->addLocal(Local);
515 }
516
517 virtual void emitDestruction() {}
518 virtual bool emitDestructors(const Expr *E = nullptr) { return true; }
519 virtual bool destroyLocals(const Expr *E = nullptr) { return true; }
520 VariableScope *getParent() const { return Parent; }
521 ScopeKind getKind() const { return Kind; }
522
523protected:
524 /// Compiler instance.
526 /// Link to the parent scope.
528 const ValueDecl *ValDecl = nullptr;
530};
531
532/// Generic scope for local variables.
533template <class Emitter> class LocalScope : public VariableScope<Emitter> {
534public:
536 : VariableScope<Emitter>(Ctx, nullptr, Kind) {}
538 : VariableScope<Emitter>(Ctx, VD) {}
539
540 /// Emit a Destroy op for this scope.
541 ~LocalScope() override {
542 if (!Idx)
543 return;
544 this->Ctx->emitDestroy(*Idx, SourceInfo{});
545 removeStoredOpaqueValues();
546 }
547
548 /// Overriden to support explicit destruction.
549 void emitDestruction() override {
550 if (!Idx)
551 return;
552
553 this->emitDestructors();
554 this->Ctx->emitDestroy(*Idx, SourceInfo{});
555 }
556
557 /// Explicit destruction of local variables.
558 bool destroyLocals(const Expr *E = nullptr) override {
559 if (!Idx)
560 return true;
561
562 // NB: We are *not* resetting Idx here as to allow multiple
563 // calls to destroyLocals().
564 bool Success = this->emitDestructors(E);
565 this->Ctx->emitDestroy(*Idx, E);
566 return Success;
567 }
568
569 void addLocal(const Scope::Local &Local) override {
570 if (!Idx) {
571 Idx = static_cast<unsigned>(this->Ctx->Descriptors.size());
572 this->Ctx->Descriptors.emplace_back();
573 this->Ctx->emitInitScope(*Idx, {});
574 }
575
576 this->Ctx->Descriptors[*Idx].emplace_back(Local);
577 }
578
579 bool emitDestructors(const Expr *E = nullptr) override {
580 if (!Idx)
581 return true;
582 // Emit destructor calls for local variables of record
583 // type with a destructor.
584 for (Scope::Local &Local : llvm::reverse(this->Ctx->Descriptors[*Idx])) {
585 if (Local.Desc->hasTrivialDtor())
586 continue;
587 if (!this->Ctx->emitGetPtrLocal(Local.Offset, E))
588 return false;
589
590 if (!this->Ctx->emitDestruction(Local.Desc, Local.Desc->getLoc()))
591 return false;
592
593 if (!this->Ctx->emitPopPtr(E))
594 return false;
595 removeIfStoredOpaqueValue(Local);
596 }
597 return true;
598 }
599
601 if (!Idx)
602 return;
603
604 for (const Scope::Local &Local : this->Ctx->Descriptors[*Idx]) {
605 removeIfStoredOpaqueValue(Local);
606 }
607 }
608
610 if (const auto *OVE =
611 llvm::dyn_cast_if_present<OpaqueValueExpr>(Local.Desc->asExpr())) {
612 if (auto It = this->Ctx->OpaqueExprs.find(OVE);
613 It != this->Ctx->OpaqueExprs.end())
614 this->Ctx->OpaqueExprs.erase(It);
615 };
616 }
617
618 /// Index of the scope in the chain.
619 UnsignedOrNone Idx = std::nullopt;
620};
621
622/// Scope for storage declared in a compound statement.
623// FIXME: Remove?
624template <class Emitter> class BlockScope final : public LocalScope<Emitter> {
625public:
627 : LocalScope<Emitter>(Ctx, Kind) {}
628};
629
630template <class Emitter> class ArrayIndexScope final {
631public:
632 ArrayIndexScope(Compiler<Emitter> *Ctx, uint64_t Index) : Ctx(Ctx) {
633 OldArrayIndex = Ctx->ArrayIndex;
634 Ctx->ArrayIndex = Index;
635 }
636
637 ~ArrayIndexScope() { Ctx->ArrayIndex = OldArrayIndex; }
638
639private:
641 std::optional<uint64_t> OldArrayIndex;
642};
643
644template <class Emitter> class SourceLocScope final {
645public:
646 SourceLocScope(Compiler<Emitter> *Ctx, const Expr *DefaultExpr) : Ctx(Ctx) {
647 assert(DefaultExpr);
648 // We only switch if the current SourceLocDefaultExpr is null.
649 if (!Ctx->SourceLocDefaultExpr) {
650 Enabled = true;
651 Ctx->SourceLocDefaultExpr = DefaultExpr;
652 }
653 }
654
656 if (Enabled)
657 Ctx->SourceLocDefaultExpr = nullptr;
658 }
659
660private:
662 bool Enabled = false;
663};
664
665template <class Emitter> class InitLinkScope final {
666public:
668 Ctx->InitStack.push_back(std::move(Link));
669 }
670
671 ~InitLinkScope() { this->Ctx->InitStack.pop_back(); }
672
673private:
675};
676
677template <class Emitter> class InitStackScope final {
678public:
680 : Ctx(Ctx), OldValue(Ctx->InitStackActive) {
681 Ctx->InitStackActive = Active;
682 }
683
684 ~InitStackScope() { this->Ctx->InitStackActive = OldValue; }
685
686private:
688 bool OldValue;
689};
690
691} // namespace interp
692} // namespace clang
693
694#endif
#define V(N, I)
Definition: ASTContext.h:3597
NodeId Parent
Definition: ASTDiff.cpp:191
StringRef P
const Decl * D
enum clang::sema::@1840::IndirectLocalPathEntry::EntryKind Kind
Expr * E
llvm::MachO::Record Record
Definition: MachO.h:31
SourceLocation Loc
Definition: SemaObjC.cpp:754
__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:4289
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:4486
Represents the index of the current element of an array being initialized by an ArrayInitLoopExpr.
Definition: Expr.h:5957
Represents a loop initializing the elements of an array.
Definition: Expr.h:5904
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition: Expr.h:2723
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Definition: ExprCXX.h:2990
Represents an attribute applied to a statement.
Definition: Stmt.h:2203
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3974
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:6560
BreakStmt - This represents a break.
Definition: Stmt.h:3135
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition: ExprCXX.h:5470
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1494
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:723
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1549
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1271
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1378
Represents a delete expression for memory deallocation and destructor calls, e.g.
Definition: ExprCXX.h:2620
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition: ExprCXX.h:481
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:1753
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Definition: ExprCXX.h:2349
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Definition: ExprCXX.h:4303
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:768
Represents a list-initialization with parenthesis.
Definition: ExprCXX.h:5135
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:526
A rewritten comparison expression that was originally written using operator syntax.
Definition: ExprCXX.h:286
An expression "T()" which creates an rvalue of a non-class type T.
Definition: ExprCXX.h:2198
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:800
Represents the this expression in C++.
Definition: ExprCXX.h:1155
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:1209
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:848
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:1069
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2879
CaseStmt - Represent a case statement.
Definition: Stmt.h:1920
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
Definition: Expr.h:3612
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition: Expr.h:4784
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:4236
CompoundLiteralExpr - [C99 6.5.2.5].
Definition: Expr.h:3541
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1720
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:196
ConstantExpr - An expression that occurs in a constant context and optionally the result of evaluatin...
Definition: Expr.h:1084
ContinueStmt - This represents a continue.
Definition: Stmt.h:3119
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:4655
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1272
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition: Stmt.h:1611
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
DoStmt - This represents a 'do/while' stmt.
Definition: Stmt.h:2832
Represents a reference to #emded data.
Definition: Expr.h:5062
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
Definition: ExprCXX.h:3655
This represents one expression.
Definition: Expr.h:112
An expression trait intrinsic.
Definition: ExprCXX.h:3063
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition: Expr.h:6500
RoundingMode getRoundingMode() const
Definition: LangOptions.h:850
ForStmt - This represents a 'for (init;cond;inc)' stmt.
Definition: Stmt.h:2888
Represents a function declaration or definition.
Definition: Decl.h:1999
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
Definition: Expr.h:4859
Represents a C11 generic selection.
Definition: Expr.h:6114
IfStmt - This represents an if/then/else.
Definition: Stmt.h:2259
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1....
Definition: Expr.h:1733
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:5993
Describes an C or C++ initializer list.
Definition: Expr.h:5235
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1970
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4914
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:3300
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:88
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:128
ObjCEncodeExpr, used for @encode in Objective-C.
Definition: ExprObjC.h:409
ObjCStringLiteral, used for Objective-C string literals i.e.
Definition: ExprObjC.h:52
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
Definition: Expr.h:2529
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition: Expr.h:1180
ParenExpr - This represents a parenthesized expression, e.g.
Definition: Expr.h:2184
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:2007
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:6692
A (possibly-)qualified type.
Definition: TypeBase.h:937
Represents a struct/union/class.
Definition: Decl.h:4309
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: TypeBase.h:6502
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
Definition: Expr.h:7364
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:505
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Definition: Stmt.h:3160
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:4579
Represents an expression that computes the length of a parameter pack.
Definition: ExprCXX.h:4435
Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(),...
Definition: Expr.h:4953
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:4531
Stmt - This represents one statement.
Definition: Stmt.h:85
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1801
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:4658
SwitchStmt - This represents a 'switch' stmt.
Definition: Stmt.h:2509
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition: ExprCXX.h:2890
bool isAnyComplexType() const
Definition: TypeBase.h:8715
bool isVectorType() const
Definition: TypeBase.h:8719
const T * getAs() const
Member-template getAs<specific type>'.
Definition: TypeBase.h:9159
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition: Expr.h:2627
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition: Expr.h:2246
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:711
Represents a variable declaration or definition.
Definition: Decl.h:925
WhileStmt - This represents a 'while' stmt.
Definition: Stmt.h:2697
ArrayIndexScope(Compiler< Emitter > *Ctx, uint64_t Index)
Definition: Compiler.h:632
Scope for storage declared in a compound statement.
Definition: Compiler.h:624
BlockScope(Compiler< Emitter > *Ctx, ScopeKind Kind=ScopeKind::Block)
Definition: Compiler.h:626
A memory block, either on the stack or in the heap.
Definition: InterpBlock.h:44
Compilation context for expressions.
Definition: Compiler.h:110
llvm::SmallVector< InitLink > InitStack
Definition: Compiler.h:438
OptLabelTy BreakLabel
Point to break to.
Definition: Compiler.h:450
VarCreationState visitVarDecl(const VarDecl *VD, bool Toplevel=false, bool IsConstexprUnknown=false)
Creates and initializes a variable from the given decl.
Definition: Compiler.cpp:4798
bool VisitArrayInitIndexExpr(const ArrayInitIndexExpr *E)
Definition: Compiler.cpp:2411
bool VisitCXXDeleteExpr(const CXXDeleteExpr *E)
Definition: Compiler.cpp:3791
bool VisitOffsetOfExpr(const OffsetOfExpr *E)
Definition: Compiler.cpp:3382
bool visitContinueStmt(const ContinueStmt *S)
Definition: Compiler.cpp:5872
bool VisitCharacterLiteral(const CharacterLiteral *E)
Definition: Compiler.cpp:2650
PrimType classifyPrim(const Expr *E) const
Classifies a known primitive expression.
Definition: Compiler.h:270
bool visitArrayElemInit(unsigned ElemIndex, const Expr *Init, OptPrimType InitT)
Pointer to the array(not the element!) must be on the stack when calling this.
Definition: Compiler.cpp:2069
bool VisitCXXParenListInitExpr(const CXXParenListInitExpr *E)
Definition: Compiler.cpp:2158
bool VisitConceptSpecializationExpr(const ConceptSpecializationExpr *E)
Definition: Compiler.cpp:3910
bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E)
Definition: Compiler.cpp:2996
bool visitBool(const Expr *E)
Visits an expression and converts it to a boolean.
Definition: Compiler.cpp:4236
bool VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *E)
Definition: Compiler.cpp:5326
bool visitDeclAndReturn(const VarDecl *VD, bool ConstantContext) override
Toplevel visitDeclAndReturn().
Definition: Compiler.cpp:4736
PrimType classifyPrim(QualType Ty) const
Classifies a known primitive type.
Definition: Compiler.h:263
bool VisitTypeTraitExpr(const TypeTraitExpr *E)
Definition: Compiler.cpp:3056
bool VisitLambdaExpr(const LambdaExpr *E)
Definition: Compiler.cpp:3076
bool VisitMemberExpr(const MemberExpr *E)
Definition: Compiler.cpp:2355
llvm::DenseMap< const OpaqueValueExpr *, unsigned > OpaqueExprs
OpaqueValueExpr to location mapping.
Definition: Compiler.h:416
bool VisitBinaryOperator(const BinaryOperator *E)
Definition: Compiler.cpp:848
bool visitAttributedStmt(const AttributedStmt *S)
Definition: Compiler.cpp:5974
bool VisitPackIndexingExpr(const PackIndexingExpr *E)
Definition: Compiler.cpp:3949
VarCreationState visitDecl(const VarDecl *VD, bool IsConstexprUnknown=false)
Definition: Compiler.cpp:4707
bool visitAPValueInitializer(const APValue &Val, const Expr *E, QualType T)
Definition: Compiler.cpp:4931
bool VisitArraySubscriptExpr(const ArraySubscriptExpr *E)
Definition: Compiler.cpp:1758
bool VisitCallExpr(const CallExpr *E)
Definition: Compiler.cpp:5095
std::optional< uint64_t > ArrayIndex
Current argument index. Needed to emit ArrayInitIndexExpr.
Definition: Compiler.h:422
bool VisitPseudoObjectExpr(const PseudoObjectExpr *E)
Definition: Compiler.cpp:3925
bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E)
Definition: Compiler.cpp:3137
const Function * getFunction(const FunctionDecl *FD)
Returns a function for the given FunctionDecl.
Definition: Compiler.cpp:4649
void emitCleanup()
Emits scope cleanup instructions.
Definition: Compiler.cpp:6964
bool VisitFixedPointBinOp(const BinaryOperator *E)
Definition: Compiler.cpp:1590
bool VisitCastExpr(const CastExpr *E)
Definition: Compiler.cpp:220
bool VisitObjCEncodeExpr(const ObjCEncodeExpr *E)
Definition: Compiler.cpp:2615
bool VisitFixedPointUnaryOperator(const UnaryOperator *E)
Definition: Compiler.cpp:1675
bool VisitComplexUnaryOperator(const UnaryOperator *E)
Definition: Compiler.cpp:6580
llvm::DenseMap< const SwitchCase *, LabelTy > CaseMap
Definition: Compiler.h:116
bool VisitBlockExpr(const BlockExpr *E)
Definition: Compiler.cpp:3807
bool visitAPValue(const APValue &Val, PrimType ValType, const Expr *E)
Visit an APValue.
Definition: Compiler.cpp:4903
bool VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *E)
Definition: Compiler.cpp:3417
bool VisitLogicalBinOp(const BinaryOperator *E)
Definition: Compiler.cpp:1089
bool visitCompoundStmt(const CompoundStmt *S)
Definition: Compiler.cpp:5484
Context & Ctx
Current compilation context.
Definition: Compiler.h:119
bool visitDeclRef(const ValueDecl *D, const Expr *E)
Visit the given decl as if we have a reference to it.
Definition: Compiler.cpp:6795
bool visitBreakStmt(const BreakStmt *S)
Definition: Compiler.cpp:5861
bool visitExpr(const Expr *E, bool DestroyToplevelScope) override
Definition: Compiler.cpp:4654
bool visitForStmt(const ForStmt *S)
Definition: Compiler.cpp:5752
bool VisitDeclRefExpr(const DeclRefExpr *E)
Definition: Compiler.cpp:6959
bool VisitOpaqueValueExpr(const OpaqueValueExpr *E)
Definition: Compiler.cpp:2451
bool VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E)
Definition: Compiler.cpp:2420
OptLabelTy DefaultLabel
Default case label.
Definition: Compiler.h:456
bool VisitStmtExpr(const StmtExpr *E)
Definition: Compiler.cpp:4159
bool VisitBuiltinBitCastExpr(const BuiltinBitCastExpr *E)
Definition: Compiler.cpp:784
bool VisitFixedPointLiteral(const FixedPointLiteral *E)
Definition: Compiler.cpp:830
const FunctionDecl * CompilingFunction
Definition: Compiler.h:458
bool VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E)
Definition: Compiler.cpp:5340
VariableScope< Emitter > * VarScope
Current scope.
Definition: Compiler.h:419
VariableScope< Emitter > * ContinueVarScope
Scope to cleanup until when we see a continue statement.
Definition: Compiler.h:452
bool VisitCXXNewExpr(const CXXNewExpr *E)
Definition: Compiler.cpp:3533
const ValueDecl * InitializingDecl
Definition: Compiler.h:436
bool VisitCompoundAssignOperator(const CompoundAssignOperator *E)
Definition: Compiler.cpp:2767
bool visit(const Expr *E) override
Evaluates an expression and places the result on the stack.
Definition: Compiler.cpp:4194
bool delegate(const Expr *E)
Just pass evaluation on to E.
Definition: Compiler.cpp:4187
bool discard(const Expr *E)
Evaluates an expression for side effects and discards the result.
Definition: Compiler.cpp:4181
bool VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *E)
Definition: Compiler.cpp:5333
CaseMap CaseLabels
Switch case mapping.
Definition: Compiler.h:445
Record * getRecord(QualType Ty)
Returns a record from a record or pointer type.
Definition: Compiler.cpp:4637
const RecordType * getRecordTy(QualType Ty)
Returns a record type from a record or pointer type.
Definition: Compiler.cpp:4631
bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E)
Definition: Compiler.cpp:4121
bool visitInitList(ArrayRef< const Expr * > Inits, const Expr *ArrayFiller, const Expr *E)
Definition: Compiler.cpp:1802
bool VisitSizeOfPackExpr(const SizeOfPackExpr *E)
Definition: Compiler.cpp:3476
bool VisitPredefinedExpr(const PredefinedExpr *E)
Definition: Compiler.cpp:3116
bool VisitSourceLocExpr(const SourceLocExpr *E)
Definition: Compiler.cpp:3326
Compiler(Context &Ctx, Program &P, Tys &&...Args)
Initializes the compiler and the backend emitter.
Definition: Compiler.h:126
bool visitDeclStmt(const DeclStmt *DS, bool EvaluateConditionDecl=false)
Definition: Compiler.cpp:5550
bool VisitExtVectorElementExpr(const ExtVectorElementExpr *E)
Definition: Compiler.cpp:4048
bool VisitObjCStringLiteral(const ObjCStringLiteral *E)
Definition: Compiler.cpp:2608
bool VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *E)
Definition: Compiler.cpp:3069
bool visitInitializer(const Expr *E)
Compiles an initializer.
Definition: Compiler.cpp:4222
const Expr * SourceLocDefaultExpr
DefaultInit- or DefaultArgExpr, needed for SourceLocExpr.
Definition: Compiler.h:425
bool VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *E)
Definition: Compiler.cpp:2977
bool VisitPointerArithBinOp(const BinaryOperator *E)
Perform addition/subtraction of a pointer and an integer or subtraction of two pointers.
Definition: Compiler.cpp:1011
bool visitCallArgs(ArrayRef< const Expr * > Args, const FunctionDecl *FuncDecl, bool Activate, bool IsOperatorCall)
Definition: Compiler.cpp:2091
bool VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *E)
Definition: Compiler.cpp:3492
bool visitDefaultStmt(const DefaultStmt *S)
Definition: Compiler.cpp:5968
typename Emitter::LabelTy LabelTy
Definition: Compiler.h:113
bool VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *E)
Definition: Compiler.cpp:3186
bool visitStmt(const Stmt *S)
Definition: Compiler.cpp:5434
bool VisitExpressionTraitExpr(const ExpressionTraitExpr *E)
Definition: Compiler.cpp:3860
bool VisitVectorUnaryOperator(const UnaryOperator *E)
Definition: Compiler.cpp:6688
bool VisitCXXConstructExpr(const CXXConstructExpr *E)
Definition: Compiler.cpp:3206
bool VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E)
Definition: Compiler.cpp:5348
bool VisitObjCBoxedExpr(const ObjCBoxedExpr *E)
Definition: Compiler.cpp:4108
unsigned allocateLocalPrimitive(DeclTy &&Decl, PrimType Ty, bool IsConst, const ValueDecl *ExtendingDecl=nullptr, ScopeKind SC=ScopeKind::Block, bool IsConstexprUnknown=false)
Creates a local primitive value.
Definition: Compiler.cpp:4551
bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E)
Definition: Compiler.cpp:3500
bool VisitRecoveryExpr(const RecoveryExpr *E)
Definition: Compiler.cpp:3954
bool VisitRequiresExpr(const RequiresExpr *E)
Definition: Compiler.cpp:3900
bool Initializing
Flag inidicating if we're initializing an already created variable.
Definition: Compiler.h:435
bool visitReturnStmt(const ReturnStmt *RS)
Definition: Compiler.cpp:5572
bool VisitCXXThrowExpr(const CXXThrowExpr *E)
Definition: Compiler.cpp:3129
bool VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E)
Definition: Compiler.cpp:2164
bool VisitChooseExpr(const ChooseExpr *E)
Definition: Compiler.cpp:3487
bool visitFunc(const FunctionDecl *F) override
Definition: Compiler.cpp:6318
bool visitCXXForRangeStmt(const CXXForRangeStmt *S)
Definition: Compiler.cpp:5806
bool visitCaseStmt(const CaseStmt *S)
Definition: Compiler.cpp:5962
bool VisitComplexBinOp(const BinaryOperator *E)
Definition: Compiler.cpp:1150
llvm::DenseMap< const ValueDecl *, Scope::Local > Locals
Variable to storage mapping.
Definition: Compiler.h:413
bool VisitAbstractConditionalOperator(const AbstractConditionalOperator *E)
Definition: Compiler.cpp:2487
bool VisitCXXTypeidExpr(const CXXTypeidExpr *E)
Definition: Compiler.cpp:3821
UnsignedOrNone allocateTemporary(const Expr *E)
Definition: Compiler.cpp:4608
bool VisitBuiltinCallExpr(const CallExpr *E, unsigned BuiltinID)
Definition: Compiler.cpp:4997
OptLabelTy ContinueLabel
Point to continue to.
Definition: Compiler.h:454
bool VisitImplicitValueInitExpr(const ImplicitValueInitExpr *E)
Definition: Compiler.cpp:1694
typename Emitter::AddrTy AddrTy
Definition: Compiler.h:114
bool VisitCXXRewrittenBinaryOperator(const CXXRewrittenBinaryOperator *E)
Definition: Compiler.cpp:3919
OptPrimType classify(QualType Ty) const
Definition: Compiler.h:258
OptPrimType ReturnType
Type of the expression returned by the function.
Definition: Compiler.h:442
bool VisitUnaryOperator(const UnaryOperator *E)
Definition: Compiler.cpp:6353
bool VisitFloatCompoundAssignOperator(const CompoundAssignOperator *E)
Definition: Compiler.cpp:2657
OptPrimType classify(const Expr *E) const
Definition: Compiler.h:257
bool VisitGenericSelectionExpr(const GenericSelectionExpr *E)
Definition: Compiler.cpp:3481
bool visitDoStmt(const DoStmt *S)
Definition: Compiler.cpp:5719
bool VisitIntegerLiteral(const IntegerLiteral *E)
Definition: Compiler.cpp:789
bool VisitInitListExpr(const InitListExpr *E)
Definition: Compiler.cpp:2153
UnsignedOrNone allocateLocal(DeclTy &&Decl, QualType Ty=QualType(), const ValueDecl *ExtendingDecl=nullptr, ScopeKind=ScopeKind::Block, bool IsConstexprUnknown=false)
Allocates a space storing a local given its type.
Definition: Compiler.cpp:4571
bool VisitVectorBinOp(const BinaryOperator *E)
Definition: Compiler.cpp:1378
bool VisitStringLiteral(const StringLiteral *E)
Definition: Compiler.cpp:2551
bool VisitParenExpr(const ParenExpr *E)
Definition: Compiler.cpp:843
bool VisitCXXNoexceptExpr(const CXXNoexceptExpr *E)
Definition: Compiler.cpp:3197
bool VisitShuffleVectorExpr(const ShuffleVectorExpr *E)
Definition: Compiler.cpp:4005
bool VisitPointerCompoundAssignOperator(const CompoundAssignOperator *E)
Definition: Compiler.cpp:2730
VariableScope< Emitter > * BreakVarScope
Scope to cleanup until when we see a break statement.
Definition: Compiler.h:448
std::optional< LabelTy > OptLabelTy
Definition: Compiler.h:115
bool DiscardResult
Flag indicating if return value is to be discarded.
Definition: Compiler.h:428
bool VisitEmbedExpr(const EmbedExpr *E)
Definition: Compiler.cpp:2186
bool VisitConvertVectorExpr(const ConvertVectorExpr *E)
Definition: Compiler.cpp:3966
bool VisitCXXThisExpr(const CXXThisExpr *E)
Definition: Compiler.cpp:5369
bool VisitConstantExpr(const ConstantExpr *E)
Definition: Compiler.cpp:2170
bool VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *E)
Definition: Compiler.cpp:2215
bool visitSwitchStmt(const SwitchStmt *S)
Definition: Compiler.cpp:5883
bool canClassify(QualType T) const
Definition: Compiler.h:260
bool VisitCXXUuidofExpr(const CXXUuidofExpr *E)
Definition: Compiler.cpp:3866
bool VisitExprWithCleanups(const ExprWithCleanups *E)
Definition: Compiler.cpp:2889
bool visitAsLValue(const Expr *E)
Definition: Compiler.cpp:4230
bool visitWhileStmt(const WhileStmt *S)
Definition: Compiler.cpp:5679
bool visitIfStmt(const IfStmt *IS)
Definition: Compiler.cpp:5609
bool VisitAddrLabelExpr(const AddrLabelExpr *E)
Definition: Compiler.cpp:3959
bool canClassify(const Expr *E) const
Definition: Compiler.h:259
bool VisitFloatingLiteral(const FloatingLiteral *E)
Definition: Compiler.cpp:797
Program & P
Program to link to.
Definition: Compiler.h:121
bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E)
Definition: Compiler.cpp:2897
bool VisitGNUNullExpr(const GNUNullExpr *E)
Definition: Compiler.cpp:5358
bool VisitImaginaryLiteral(const ImaginaryLiteral *E)
Definition: Compiler.cpp:806
bool VisitSYCLUniqueStableNameExpr(const SYCLUniqueStableNameExpr *E)
Definition: Compiler.cpp:2626
bool visitCXXTryStmt(const CXXTryStmt *S)
Definition: Compiler.cpp:6005
Holds all information required to evaluate constexpr code in a module.
Definition: Context.h:41
const LangOptions & getLangOpts() const
Returns the language options.
Definition: Context.cpp:276
bool canClassify(QualType T)
Definition: Context.h:96
OptPrimType classify(QualType T) const
Classifies a type.
Definition: Context.cpp:310
Scope used to handle temporaries in toplevel variable declarations.
Definition: Compiler.cpp:39
Bytecode function.
Definition: Function.h:86
InitLinkScope(Compiler< Emitter > *Ctx, InitLink &&Link)
Definition: Compiler.h:667
InitStackScope(Compiler< Emitter > *Ctx, bool Active)
Definition: Compiler.h:679
When generating code for e.g.
Definition: Compiler.cpp:195
Generic scope for local variables.
Definition: Compiler.h:533
~LocalScope() override
Emit a Destroy op for this scope.
Definition: Compiler.h:541
bool destroyLocals(const Expr *E=nullptr) override
Explicit destruction of local variables.
Definition: Compiler.h:558
LocalScope(Compiler< Emitter > *Ctx, const ValueDecl *VD)
Definition: Compiler.h:537
bool emitDestructors(const Expr *E=nullptr) override
Definition: Compiler.h:579
void emitDestruction() override
Overriden to support explicit destruction.
Definition: Compiler.h:549
void removeIfStoredOpaqueValue(const Scope::Local &Local)
Definition: Compiler.h:609
void addLocal(const Scope::Local &Local) override
Definition: Compiler.h:569
LocalScope(Compiler< Emitter > *Ctx, ScopeKind Kind=ScopeKind::Block)
Definition: Compiler.h:535
Sets the context for break/continue statements.
Definition: Compiler.cpp:113
Scope used to handle initialization methods.
Definition: Compiler.cpp:59
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:73
SourceLocScope(Compiler< Emitter > *Ctx, const Expr *DefaultExpr)
Definition: Compiler.h:646
Scope chain managing the variable lifetimes.
Definition: Compiler.h:465
void addExtended(const Scope::Local &Local, const ValueDecl *ExtendingDecl)
Definition: Compiler.h:479
void addForScopeKind(const Scope::Local &Local, ScopeKind Kind)
Like addExtended, but adds to the nearest scope of the given kind.
Definition: Compiler.h:501
Compiler< Emitter > * Ctx
Compiler instance.
Definition: Compiler.h:525
virtual bool emitDestructors(const Expr *E=nullptr)
Definition: Compiler.h:518
virtual bool destroyLocals(const Expr *E=nullptr)
Definition: Compiler.h:519
VariableScope * Parent
Link to the parent scope.
Definition: Compiler.h:527
VariableScope(Compiler< Emitter > *Ctx, const ValueDecl *VD, ScopeKind Kind=ScopeKind::Block)
Definition: Compiler.h:467
virtual void addLocal(const Scope::Local &Local)
Definition: Compiler.h:475
ScopeKind getKind() const
Definition: Compiler.h:521
VariableScope * getParent() const
Definition: Compiler.h:520
virtual void emitDestruction()
Definition: Compiler.h:517
#define bool
Definition: gpuintrin.h:32
llvm::APFloat APFloat
Definition: Floating.h:27
static bool Activate(InterpState &S, CodePtr OpPC)
Definition: Interp.h:1993
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.
@ Success
Annotation was successful.
@ Link
'link' clause, allowed on 'declare' construct.
const FunctionProtoType * T
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:95
static VarCreationState NotCreated()
Definition: Compiler.h:99
std::optional< bool > S
Definition: Compiler.h:96