clang 19.0.0git
CoroutineStmtBuilder.h
Go to the documentation of this file.
1//===- CoroutineStmtBuilder.h - Implicit coroutine stmt builder -*- 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// This file defines CoroutineStmtBuilder, a class for building the implicit
9// statements required for building a coroutine body.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H
14#define LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H
15
16#include "clang/AST/Decl.h"
17#include "clang/AST/ExprCXX.h"
18#include "clang/AST/StmtCXX.h"
21
22namespace clang {
23
25 Sema &S;
26 FunctionDecl &FD;
28 bool IsValid = true;
30 SmallVector<Stmt *, 4> ParamMovesVector;
31 const bool IsPromiseDependentType;
32 CXXRecordDecl *PromiseRecordDecl = nullptr;
33
34public:
35 /// Construct a CoroutineStmtBuilder and initialize the promise
36 /// statement and initial/final suspends from the FunctionScopeInfo.
38 Stmt *Body);
39
40 /// Build the coroutine body statements, including the
41 /// "promise dependent" statements when the promise type is not dependent.
42 bool buildStatements();
43
44 /// Build the coroutine body statements that require a non-dependent
45 /// promise type in order to construct.
46 ///
47 /// For example different new/delete overloads are selected depending on
48 /// if the promise type provides `unhandled_exception()`, and therefore they
49 /// cannot be built until the promise type is complete so that we can perform
50 /// name lookup.
52
53 bool isInvalid() const { return !this->IsValid; }
54
55private:
56 bool makePromiseStmt();
57 bool makeInitialAndFinalSuspend();
58 bool makeNewAndDeleteExpr();
59 bool makeOnFallthrough();
60 bool makeOnException();
61 bool makeReturnObject();
62 bool makeGroDeclAndReturnStmt();
63 bool makeReturnOnAllocFailure();
64};
65
66} // end namespace clang
67
68#endif // LLVM_CLANG_LIB_SEMA_COROUTINESTMTBUILDER_H
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::Preprocessor interface.
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
bool buildDependentStatements()
Build the coroutine body statements that require a non-dependent promise type in order to construct.
bool buildStatements()
Build the coroutine body statements, including the "promise dependent" statements when the promise ty...
Represents a function declaration or definition.
Definition: Decl.h:1971
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:450
Encodes a location in the source.
Stmt - This represents one statement.
Definition: Stmt.h:84
Retains information about a function, method, or block that is currently being parsed.
Definition: ScopeInfo.h:104
The JSON file list parser is used to communicate input to InstallAPI.