[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / lib / AST / Interp / ByteCodeStmtGen.h
blob64e03587ab2112dad4fb29609ebf8bad61770d81
1 //===--- ByteCodeStmtGen.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.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_CLANG_AST_INTERP_BYTECODESTMTGEN_H
14 #define LLVM_CLANG_AST_INTERP_BYTECODESTMTGEN_H
16 #include "ByteCodeEmitter.h"
17 #include "ByteCodeExprGen.h"
18 #include "EvalEmitter.h"
19 #include "PrimType.h"
20 #include "clang/AST/StmtVisitor.h"
22 namespace clang {
23 namespace interp {
25 template <class Emitter> class LoopScope;
26 template <class Emitter> class SwitchScope;
27 template <class Emitter> class LabelScope;
29 /// Compilation context for statements.
30 template <class Emitter>
31 class ByteCodeStmtGen final : public ByteCodeExprGen<Emitter> {
32 using LabelTy = typename Emitter::LabelTy;
33 using AddrTy = typename Emitter::AddrTy;
34 using OptLabelTy = std::optional<LabelTy>;
35 using CaseMap = llvm::DenseMap<const SwitchCase *, LabelTy>;
37 public:
38 template<typename... Tys>
39 ByteCodeStmtGen(Tys&&... Args)
40 : ByteCodeExprGen<Emitter>(std::forward<Tys>(Args)...) {}
42 protected:
43 bool visitFunc(const FunctionDecl *F) override;
45 private:
46 friend class LabelScope<Emitter>;
47 friend class LoopScope<Emitter>;
48 friend class SwitchScope<Emitter>;
50 // Statement visitors.
51 bool visitStmt(const Stmt *S);
52 bool visitCompoundStmt(const CompoundStmt *S);
53 bool visitLoopBody(const Stmt *S);
54 bool visitDeclStmt(const DeclStmt *DS);
55 bool visitReturnStmt(const ReturnStmt *RS);
56 bool visitIfStmt(const IfStmt *IS);
57 bool visitWhileStmt(const WhileStmt *S);
58 bool visitDoStmt(const DoStmt *S);
59 bool visitForStmt(const ForStmt *S);
60 bool visitCXXForRangeStmt(const CXXForRangeStmt *S);
61 bool visitBreakStmt(const BreakStmt *S);
62 bool visitContinueStmt(const ContinueStmt *S);
63 bool visitSwitchStmt(const SwitchStmt *S);
64 bool visitCaseStmt(const CaseStmt *S);
65 bool visitDefaultStmt(const DefaultStmt *S);
66 bool visitAsmStmt(const AsmStmt *S);
67 bool visitAttributedStmt(const AttributedStmt *S);
68 bool visitCXXTryStmt(const CXXTryStmt *S);
70 bool emitLambdaStaticInvokerBody(const CXXMethodDecl *MD);
72 /// Type of the expression returned by the function.
73 std::optional<PrimType> ReturnType;
75 /// Switch case mapping.
76 CaseMap CaseLabels;
78 /// Point to break to.
79 OptLabelTy BreakLabel;
80 /// Point to continue to.
81 OptLabelTy ContinueLabel;
82 /// Default case label.
83 OptLabelTy DefaultLabel;
86 extern template class ByteCodeExprGen<EvalEmitter>;
88 } // namespace interp
89 } // namespace clang
91 #endif