This repository was archived by the owner on Nov 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathCoroutineStmtBuilder.h
73 lines (61 loc) · 2.46 KB
/
CoroutineStmtBuilder.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//===- CoroutineStmtBuilder.h - Implicit coroutine stmt builder -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//===----------------------------------------------------------------------===//
//
// This file defines CoroutineStmtBuilder, a class for building the implicit
// statements required for building a coroutine body.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H
#define LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H
#include "clang/AST/Decl.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/StmtCXX.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/SemaInternal.h"
namespace clang {
class CoroutineStmtBuilder : public CoroutineBodyStmt::CtorArgs {
Sema &S;
FunctionDecl &FD;
sema::FunctionScopeInfo &Fn;
bool IsValid = true;
SourceLocation Loc;
SmallVector<Stmt *, 4> ParamMovesVector;
const bool IsPromiseDependentType;
CXXRecordDecl *PromiseRecordDecl = nullptr;
public:
/// \brief Construct a CoroutineStmtBuilder and initialize the promise
/// statement and initial/final suspends from the FunctionScopeInfo.
CoroutineStmtBuilder(Sema &S, FunctionDecl &FD, sema::FunctionScopeInfo &Fn,
Stmt *Body);
/// \brief Build the coroutine body statements, including the
/// "promise dependent" statements when the promise type is not dependent.
bool buildStatements();
/// \brief Build the coroutine body statements that require a non-dependent
/// promise type in order to construct.
///
/// For example different new/delete overloads are selected depending on
/// if the promise type provides `unhandled_exception()`, and therefore they
/// cannot be built until the promise type is complete so that we can perform
/// name lookup.
bool buildDependentStatements();
/// \brief Build just parameter moves. To use for rebuilding in TreeTransform.
bool buildParameterMoves();
bool isInvalid() const { return !this->IsValid; }
private:
bool makePromiseStmt();
bool makeInitialAndFinalSuspend();
bool makeNewAndDeleteExpr();
bool makeOnFallthrough();
bool makeOnException();
bool makeReturnObject();
bool makeGroDeclAndReturnStmt();
bool makeReturnOnAllocFailure();
bool makeParamMoves();
};
} // end namespace clang
#endif // LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H