14#ifndef CLANG_LIB_CIR_CODEGEN_CIRGENCLEANUP_H
15#define CLANG_LIB_CIR_CODEGEN_CIRGENCLEANUP_H
20#include "mlir/IR/Value.h"
36 class CommonBitFields {
40 enum { NumCommonBits = 3 };
48 unsigned numHandlers : 32 - NumCommonBits;
56 unsigned isNormalCleanup : 1;
59 unsigned isEHCleanup : 1;
62 unsigned isActive : 1;
65 unsigned isLifetimeMarker : 1;
68 unsigned testFlagInNormalCleanup : 1;
71 unsigned testFlagInEHCleanup : 1;
75 unsigned cleanupSize : 12;
88 : enclosingEHScope(enclosingEHScope) {
104 return enclosingEHScope;
137 Handler *getHandlers() {
return reinterpret_cast<Handler *
>(
this + 1); }
139 const Handler *getHandlers()
const {
140 return reinterpret_cast<const Handler *
>(
this + 1);
152 assert(
catchBits.numHandlers == numHandlers &&
"NumHandlers overflow?");
160 Handler *handler = &getHandlers()[i];
168 return getHandlers()[i];
196 mlir::Block *normalBlock =
nullptr;
201 unsigned fixupDepth = 0;
218 enclosingNormal(enclosingNormal), fixupDepth(fixupDepth) {
229 assert(
cleanupBits.cleanupSize == cleanupSize &&
"cleanup size overflow");
248 return enclosingNormal;
270 explicit iterator(
char *ptr) : ptr(ptr) {}
289 llvm_unreachable(
"EHScopeStack::iterator Filter");
293 llvm_unreachable(
"EHScopeStack::iterator Cleanup");
297 llvm_unreachable(
"EHScopeStack::iterator Terminate");
304 bool operator==(iterator other)
const {
return ptr == other.ptr; }
305 bool operator!=(iterator other)
const {
return ptr != other.ptr; }
318 assert(savePoint.
isValid() &&
"finding invalid savepoint");
320 "finding savepoint after pop");
321 return iterator(endOfBuffer - savePoint.size);
325 assert(!
empty() &&
"popping exception stack when not empty");
static Decl::Kind getKind(const Decl *D)
This class organizes the cross-function state that is used while generating CIR code.
A scope which attempts to handle some, possibly all, types of exceptions.
static bool classof(const EHScope *scope)
const Handler & getHandler(unsigned i) const
friend class EHScopeStack
EHCatchScope(unsigned numHandlers, EHScopeStack::stable_iterator enclosingEHScope)
unsigned getNumHandlers() const
void setHandler(unsigned i, CatchTypeInfo type, mlir::Region *region, const CXXCatchStmt *stmt)
void clearHandlerBlocks()
static size_t getSizeForNumHandlers(unsigned n)
size_t getAllocatedSize() const
EHCleanupScope(unsigned cleanupSize, unsigned fixupDepth, EHScopeStack::stable_iterator enclosingNormal, EHScopeStack::stable_iterator enclosingEH)
mlir::Block * getNormalBlock() const
EHScopeStack::Cleanup * getCleanup()
unsigned getFixupDepth() const
bool isLifetimeMarker() const
size_t getCleanupSize() const
static bool classof(const EHScope *scope)
static size_t getSizeForCleanupSize(size_t size)
Gets the size required for a lazy cleanup scope with the given cleanup-data requirements.
bool isNormalCleanup() const
EHScopeStack::stable_iterator getEnclosingNormalCleanup() const
void * getCleanupBuffer()
void setNormalBlock(mlir::Block *bb)
void setActive(bool isActive)
Information for lazily generating a cleanup.
A non-stable pointer into the scope stack.
friend class EHScopeStack
bool operator!=(iterator other) const
EHScope & operator*() const
EHScope * operator->() const
bool operator==(iterator other) const
A saved depth on the scope stack.
void popCatch()
Pops a catch scope off the stack. This is private to CIRGenException.cpp.
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.
bool empty() const
Determines whether the exception-scopes stack is empty.
iterator end() const
Returns an iterator pointing to the outermost EH scope.
iterator begin() const
Returns an iterator pointing to the innermost EH scope.
friend class EHCatchScope
friend class EHCleanupScope
A protected scope for zero-cost EH handling.
CleanupBitFields cleanupBits
void setMayThrow(bool mayThrow)
EHScopeStack::stable_iterator getEnclosingEHScope() const
CommonBitFields commonBits
EHScope(Kind kind, EHScopeStack::stable_iterator enclosingEHScope)
CXXCatchStmt - This represents a C++ catch block.
Represents a function declaration or definition.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
The MS C++ ABI needs a pointer to RTTI data plus some flags to describe the type of a catch handler,...
mlir::Region * region
The catch handler for this type.
const CXXCatchStmt * stmt
The catch handler stmt.
CatchTypeInfo type
A type info value, or null MLIR attribute for a catch-all.
The exceptions personality for a function.
bool usesFuncletPads() const
Does this personality use landingpads or the family of pad instructions designed to form funclets?
static const EHPersonality XL_CPlusPlus
static const EHPersonality GNU_ObjC_SJLJ
static const EHPersonality ZOS_CPlusPlus
static const EHPersonality GNUstep_ObjC
const char * personalityFn
const char * catchallRethrowFn
static const EHPersonality MSVC_CxxFrameHandler3
static const EHPersonality MSVC_C_specific_handler
bool isMSVCXXPersonality() const
static const EHPersonality GNU_CPlusPlus_SEH
static const EHPersonality GNU_ObjC
static const EHPersonality GNU_CPlusPlus_SJLJ
static const EHPersonality GNU_C_SJLJ
bool isMSVCPersonality() const
static const EHPersonality GNU_C
static const EHPersonality NeXT_ObjC
static const EHPersonality & get(CIRGenModule &cgm, const clang::FunctionDecl *fd)
static const EHPersonality GNU_CPlusPlus
static const EHPersonality GNU_ObjCXX
static const EHPersonality GNU_C_SEH
static const EHPersonality MSVC_except_handler
static const EHPersonality GNU_ObjC_SEH
bool isWasmPersonality() const
static const EHPersonality GNU_Wasm_CPlusPlus