clang  6.0.0svn
CoroutineStmtBuilder.h
Go to the documentation of this file.
1 //===- CoroutineStmtBuilder.h - Implicit coroutine stmt builder -*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines CoroutineStmtBuilder, a class for building the implicit
10 // statements required for building a coroutine body.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H
15 #define LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H
16 
17 #include "clang/AST/Decl.h"
18 #include "clang/AST/ExprCXX.h"
19 #include "clang/AST/StmtCXX.h"
20 #include "clang/Lex/Preprocessor.h"
22 
23 namespace clang {
24 
26  Sema &S;
27  FunctionDecl &FD;
29  bool IsValid = true;
30  SourceLocation Loc;
31  SmallVector<Stmt *, 4> ParamMovesVector;
32  const bool IsPromiseDependentType;
33  CXXRecordDecl *PromiseRecordDecl = nullptr;
34 
35 public:
36  /// \brief Construct a CoroutineStmtBuilder and initialize the promise
37  /// statement and initial/final suspends from the FunctionScopeInfo.
39  Stmt *Body);
40 
41  /// \brief Build the coroutine body statements, including the
42  /// "promise dependent" statements when the promise type is not dependent.
43  bool buildStatements();
44 
45  /// \brief Build the coroutine body statements that require a non-dependent
46  /// promise type in order to construct.
47  ///
48  /// For example different new/delete overloads are selected depending on
49  /// if the promise type provides `unhandled_exception()`, and therefore they
50  /// cannot be built until the promise type is complete so that we can perform
51  /// name lookup.
53 
54  /// \brief Build just parameter moves. To use for rebuilding in TreeTransform.
55  bool buildParameterMoves();
56 
57  bool isInvalid() const { return !this->IsValid; }
58 
59 private:
60  bool makePromiseStmt();
61  bool makeInitialAndFinalSuspend();
62  bool makeNewAndDeleteExpr();
63  bool makeOnFallthrough();
64  bool makeOnException();
65  bool makeReturnObject();
66  bool makeGroDeclAndReturnStmt();
67  bool makeReturnOnAllocFailure();
68  bool makeParamMoves();
69 };
70 
71 } // end namespace clang
72 
73 #endif // LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
Definition: Decl.h:1698
Stmt - This represents one statement.
Definition: Stmt.h:66
Retains information about a function, method, or block that is currently being parsed.
Definition: ScopeInfo.h:82
Defines the clang::Expr interface and subclasses for C++ expressions.
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:274
Defines the clang::Preprocessor interface.
bool buildStatements()
Build the coroutine body statements, including the "promise dependent" statements when the promise ty...
Encodes a location in the source.
Dataflow Directional Tag Classes.
CoroutineStmtBuilder(Sema &S, FunctionDecl &FD, sema::FunctionScopeInfo &Fn, Stmt *Body)
Construct a CoroutineStmtBuilder and initialize the promise statement and initial/final suspends from...
Represents a C++ struct/union/class.
Definition: DeclCXX.h:299
bool buildDependentStatements()
Build the coroutine body statements that require a non-dependent promise type in order to construct...
bool buildParameterMoves()
Build just parameter moves. To use for rebuilding in TreeTransform.