14#ifndef CLANG_LIB_CIR_CODEGEN_CIRGENCLEANUP_H
15#define CLANG_LIB_CIR_CODEGEN_CIRGENCLEANUP_H
20#include "mlir/IR/Value.h"
35 class CommonBitFields {
39 enum { NumCommonBits = 3 };
45 unsigned numHandlers : 32 - NumCommonBits;
53 unsigned isNormalCleanup : 1;
56 unsigned isEHCleanup : 1;
59 unsigned isActive : 1;
62 unsigned isLifetimeMarker : 1;
65 unsigned testFlagInNormalCleanup : 1;
68 unsigned testFlagInEHCleanup : 1;
72 unsigned cleanupSize : 12;
85 : enclosingEHScope(enclosingEHScope) {
100 return enclosingEHScope;
130 Handler *getHandlers() {
return reinterpret_cast<Handler *
>(
this + 1); }
132 const Handler *getHandlers()
const {
133 return reinterpret_cast<const Handler *
>(
this + 1);
145 assert(
catchBits.numHandlers == numHandlers &&
"NumHandlers overflow?");
152 getHandlers()[i].type =
type;
153 getHandlers()[i].region = region;
158 return getHandlers()[i];
186 mlir::Block *normalBlock =
nullptr;
191 unsigned fixupDepth = 0;
208 enclosingNormal(enclosingNormal), fixupDepth(fixupDepth) {
219 assert(
cleanupBits.cleanupSize == cleanupSize &&
"cleanup size overflow");
236 return enclosingNormal;
258 explicit iterator(
char *ptr) : ptr(ptr) {}
277 llvm_unreachable(
"EHScopeStack::iterator Filter");
281 llvm_unreachable(
"EHScopeStack::iterator Cleanup");
285 llvm_unreachable(
"EHScopeStack::iterator Terminate");
292 bool operator==(iterator other)
const {
return ptr == other.ptr; }
293 bool operator!=(iterator other)
const {
return ptr != other.ptr; }
306 assert(savePoint.
isValid() &&
"finding invalid savepoint");
308 "finding savepoint after pop");
309 return iterator(endOfBuffer - savePoint.size);
313 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)
void setHandler(unsigned i, CatchTypeInfo type, mlir::Region *region)
const Handler & getHandler(unsigned i) const
friend class EHScopeStack
EHCatchScope(unsigned numHandlers, EHScopeStack::stable_iterator enclosingEHScope)
unsigned getNumHandlers() const
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
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
EHScopeStack::stable_iterator getEnclosingEHScope() const
CommonBitFields commonBits
EHScope(Kind kind, EHScopeStack::stable_iterator enclosingEHScope)
Represents a function declaration or definition.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
static bool ehstackBranches()
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.
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