18#ifndef CLANG_LIB_CIR_CODEGEN_EHSCOPESTACK_H
19#define CLANG_LIB_CIR_CODEGEN_EHSCOPESTACK_H
22#include "llvm/ADT/SmallVector.h"
79 class stable_iterator {
91 bool isValid()
const {
return size >= 0; }
96 bool encloses(stable_iterator other)
const {
return size <= other.size; }
104 friend bool operator==(stable_iterator A, stable_iterator B) {
105 return A.size == B.size;
107 friend bool operator!=(stable_iterator A, stable_iterator B) {
108 return A.size != B.size;
121 virtual void anchor();
147 std::unique_ptr<char[]> startOfBuffer;
150 char *endOfBuffer =
nullptr;
153 char *startOfData =
nullptr;
187 char *allocate(
size_t size);
188 void deallocate(
size_t size);
190 void *pushCleanup(
CleanupKind kind,
size_t dataSize);
199 "Cleanup's alignment is too large.");
200 void *buffer = pushCleanup(kind,
sizeof(
T));
201 [[maybe_unused]]
Cleanup *obj =
new (buffer)
T(a...);
218 bool empty()
const {
return startOfData == endOfBuffer; }
224 return innermostNormalCleanup !=
stable_end();
230 return innermostNormalCleanup;
264 return branchFixups.back();
270 return branchFixups[i];
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
A scope which attempts to handle some, possibly all, types of exceptions.
Information for lazily generating a cleanup.
Cleanup(const Cleanup &)=default
virtual ~Cleanup()=default
virtual void emit(CIRGenFunction &cgf)=0
Emit the cleanup.
A saved depth on the scope stack.
bool strictlyEncloses(stable_iterator I) const
Returns true if this scope strictly encloses I: that is, if it encloses I and is not I.
friend class EHScopeStack
bool encloses(stable_iterator other) const
Returns true if this scope encloses I.
friend bool operator==(stable_iterator A, stable_iterator B)
friend bool operator!=(stable_iterator A, stable_iterator B)
static stable_iterator invalid()
stable_iterator()=default
void setCGF(CIRGenFunction *inCGF)
void popCleanup()
Pops a cleanup scope off the stack. This is private to CIRGenCleanup.cpp.
void popCatch()
Pops a catch scope off the stack. This is private to CIRGenException.cpp.
bool hasNormalCleanups() const
Determines whether there are any normal cleanups on the stack.
iterator find(stable_iterator savePoint) const
Turn a stable reference to a scope depth into a unstable pointer to the EH stack.
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
void pushCleanup(CleanupKind kind, As... a)
Push a lazily-created cleanup on the stack.
bool empty() const
Determines whether the exception-scopes stack is empty.
void popNullFixups()
Pops lazily-removed fixups from the end of the list.
iterator end() const
Returns an iterator pointing to the outermost EH scope.
class EHCatchScope * pushCatch(unsigned numHandlers)
Push a set of catch handlers on the stack.
bool requiresCatchOrCleanup() const
stable_iterator getInnermostActiveNormalCleanup() const
stable_iterator getInnermostEHScope() const
unsigned getNumBranchFixups() const
static stable_iterator stable_end()
Create a stable reference to the bottom of the EH stack.
BranchFixup & getBranchFixup(unsigned i)
BranchFixup & addBranchFixup()
Add a branch fixup to the current cleanup scope.
iterator begin() const
Returns an iterator pointing to the innermost EH scope.
friend class CIRGenFunction
stable_iterator getInnermostNormalCleanup() const
Returns the innermost normal cleanup on the stack, or stable_end() if there are no normal cleanups.
@ EHCleanup
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
@ NormalCleanup
Denotes a cleanup that should run when a scope is exited using normal control flow (falling off the e...
const FunctionProtoType * T
cir::BrOp initialBranch
The initial branch of the fixup.
mlir::Block * destination
The ultimate destination of the branch.
mlir::Block * optimisticBranchBlock
The block containing the terminator which needs to be modified into a switch if this fixup is resolve...
unsigned destinationIndex
The destination index value.