16 #ifndef LLVM_CLANG_LIB_CODEGEN_EHSCOPESTACK_H
17 #define LLVM_CLANG_LIB_CODEGEN_EHSCOPESTACK_H
20 #include "llvm/ADT/STLExtras.h"
21 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/IR/BasicBlock.h"
23 #include "llvm/IR/Instructions.h"
24 #include "llvm/IR/Value.h"
29 class CodeGenFunction;
68 template <
class T,
bool mightBeInstruction =
69 std::is_base_of<llvm::Value, T>::value &&
70 !std::is_base_of<llvm::Constant, T>::value &&
71 !std::is_base_of<llvm::BasicBlock, T>::value>
133 return A.Size == B.Size;
136 return A.Size != B.Size;
149 virtual void anchor();
163 F_IsNormalCleanupKind = 0x2,
164 F_IsEHCleanupKind = 0x4
197 template <
class T,
class... As>
199 typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
210 restore(CGF, llvm::index_sequence_for<As...>()).Emit(CGF, flags);
237 stable_iterator InnermostNormalCleanup;
240 stable_iterator InnermostEHScope;
261 char *allocate(
size_t Size);
262 void deallocate(
size_t Size);
268 StartOfData(nullptr), InnermostNormalCleanup(
stable_end()),
275 "Cleanup's alignment is too large.");
276 void *
Buffer = pushCleanup(Kind,
sizeof(T));
282 template <
class T,
class... As>
285 "Cleanup's alignment is too large.");
286 void *
Buffer = pushCleanup(Kind,
sizeof(T));
304 template <
class T,
class... As>
307 "Cleanup's alignment is too large.");
308 void *
Buffer = pushCleanup(Kind,
sizeof(T) + T::getExtraSize(N));
309 return new (
Buffer) T(N, A...);
313 void *
Buffer = pushCleanup(Kind, Size);
314 std::memcpy(Buffer, Cleanup, Size);
345 bool empty()
const {
return StartOfData == EndOfBuffer; }
351 return InnermostNormalCleanup !=
stable_end();
357 return InnermostNormalCleanup;
362 return InnermostEHScope;
399 return BranchFixups.back();
405 return BranchFixups[
I];
void pushTerminate()
Push a terminate handler on the stack.
bool isNormalCleanupKind() const
iterator end() const
Returns an iterator pointing to the outermost EH scope.
ConditionalCleanup(typename DominatingValue< As >::saved_type...A)
void pushCleanup(CleanupKind Kind, As...A)
Push a lazily-created cleanup on the stack.
void setIsEHCleanupKind()
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
static stable_iterator stable_end()
Create a stable reference to the bottom of the EH stack.
std::unique_ptr< llvm::MemoryBuffer > Buffer
static saved_type save(CodeGenFunction &CGF, type value)
T * pushCleanupWithExtra(CleanupKind Kind, size_t N, As...A)
Push a cleanup with non-constant storage requirements on the stack.
void pushCleanupTuple(CleanupKind Kind, std::tuple< As...> A)
Push a lazily-created cleanup on the stack. Tuple version.
A scope which attempts to handle some, possibly all, types of exceptions.
bool isForNormalCleanup() const
stable_iterator stabilize(iterator it) const
Translates an iterator into a stable_iterator.
bool requiresLandingPad() const
ConditionalCleanup stores the saved form of its parameters, then restores them and performs the clean...
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
A metaprogramming class for ensuring that a value will dominate an arbitrary position in a function...
class EHCatchScope * pushCatch(unsigned NumHandlers)
Push a set of catch handlers on the stack.
iterator begin() const
Returns an iterator pointing to the innermost EH scope.
BranchFixup & getBranchFixup(unsigned I)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
A stack of scopes which respond to exceptions, including cleanups and catch blocks.
Denotes a cleanup that should run when a scope is exited using normal control flow (falling off the e...
void popFilter()
Pops an exceptions filter off the stack.
detail::InMemoryDirectory::const_iterator I
iterator find(stable_iterator save) const
Turn a stable reference to a scope depth into a unstable pointer to the EH stack. ...
unsigned getNumBranchFixups() const
static type restore(CodeGenFunction &CGF, saved_type value)
llvm::BranchInst * InitialBranch
The initial branch of the fixup.
bool empty() const
Determines whether the exception-scopes stack is empty.
void clearFixups()
Clears the branch-fixups list.
ConditionalCleanup(SavedTuple Tuple)
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
bool containsOnlyLifetimeMarkers(stable_iterator Old) const
void popCleanup()
Pops a cleanup scope off the stack. This is private to CGCleanup.cpp.
llvm::BasicBlock * OptimisticBranchBlock
The block containing the terminator which needs to be modified into a switch if this fixup is resolve...
void popCatch()
Pops a catch scope off the stack. This is private to CGException.cpp.
llvm::BasicBlock * Destination
The ultimate destination of the branch.
A saved depth on the scope stack.
static bool needsSaving(type value)
void pushCopyOfCleanup(CleanupKind Kind, const void *Cleanup, size_t Size)
unsigned DestinationIndex
The destination index value.
void setIsNormalCleanupKind()
virtual void Emit(CodeGenFunction &CGF, Flags flags)=0
Emit the cleanup.
friend bool operator==(stable_iterator A, stable_iterator B)
__PTRDIFF_TYPE__ ptrdiff_t
A signed integer type that is the result of subtracting two pointers.
Represents a template argument.
class EHFilterScope * pushFilter(unsigned NumFilters)
Push an exceptions filter on the stack.
bool encloses(stable_iterator I) const
Returns true if this scope encloses I.
BranchFixup & addBranchFixup()
Add a branch fixup to the current cleanup scope.
void popNullFixups()
Pops lazily-removed fixups from the end of the list.
friend bool operator!=(stable_iterator A, stable_iterator B)
bool isEHCleanupKind() const
isEHCleanupKind - true if the cleanup was pushed as an EH cleanup.
static stable_iterator invalid()
stable_iterator getInnermostActiveNormalCleanup() const
void popTerminate()
Pops a terminate handler off the stack.
bool hasNormalCleanups() const
Determines whether there are any normal cleanups on the stack.
stable_iterator getInnermostEHScope() const
bool strictlyEncloses(stable_iterator I) const
Returns true if this scope strictly encloses I: that is, if it encloses I and is not I...
stable_iterator getInnermostNormalCleanup() const
Returns the innermost normal cleanup on the stack, or stable_end() if there are no normal cleanups...
An exceptions scope which filters exceptions thrown through it.
bool isForEHCleanup() const
isForEH - true if the current emission is for an EH cleanup.
Information for lazily generating a cleanup.