18#ifndef CLANG_LIB_CIR_CODEGEN_EHSCOPESTACK_H
19#define CLANG_LIB_CIR_CODEGEN_EHSCOPESTACK_H
22#include "llvm/ADT/SmallVector.h"
54 class stable_iterator {
66 bool isValid()
const {
return size >= 0; }
71 bool encloses(stable_iterator other)
const {
return size <= other.size; }
79 friend bool operator==(stable_iterator A, stable_iterator B) {
80 return A.size == B.size;
82 friend bool operator!=(stable_iterator A, stable_iterator B) {
83 return A.size != B.size;
94 class LLVM_MOVABLE_POLYMORPHIC_TYPE
Cleanup {
96 virtual void anchor();
109 F_IsNormalCleanupKind = 0x2,
110 F_IsEHCleanupKind = 0x4,
111 F_HasExitSwitch = 0x8,
152 std::unique_ptr<char[]> startOfBuffer;
155 char *endOfBuffer =
nullptr;
158 char *startOfData =
nullptr;
173 char *allocate(
size_t size);
174 void deallocate(
size_t size);
185 "Cleanup's alignment is too large.");
186 void *buffer = pushCleanup(
kind,
sizeof(T));
187 [[maybe_unused]]
Cleanup *obj =
new (buffer) T(a...);
201 template <
class T,
class... As>
204 "Cleanup's alignment is too large.");
205 void *buffer = pushCleanup(
kind,
sizeof(T) + T::getExtraSize(n));
206 return new (buffer) T(n, a...);
215 bool empty()
const {
return startOfData == endOfBuffer; }
221 return innermostNormalCleanup !=
stable_end();
227 return innermostNormalCleanup;
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
bool isEHCleanupKind() const
isEHCleanupKind - true if the cleanup was pushed as an EH cleanup.
void setIsEHCleanupKind()
bool isForNormalCleanup() const
bool isForEHCleanup() const
isForEH - true if the current emission is for an EH cleanup.
void setIsNormalCleanupKind()
bool hasExitSwitch() const
bool isNormalCleanupKind() const
Information for lazily generating a cleanup.
Cleanup(const Cleanup &)=default
virtual ~Cleanup()=default
virtual void emit(CIRGenFunction &cgf, Flags flags)=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.
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.
iterator end() const
Returns an iterator pointing to the outermost EH scope.
bool requiresCatchOrCleanup() const
stable_iterator getInnermostActiveNormalCleanup() const
stable_iterator getInnermostEHScope() const
static stable_iterator stable_end()
Create a stable reference to the bottom of the EH stack.
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.
T * pushCleanupWithExtra(CleanupKind kind, size_t n, As... a)
Push a cleanup with non-constant storage requirements on the stack.
@ 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...