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>
127 return A.Size == B.Size;
130 return A.Size != B.Size;
143 virtual void anchor();
149 F_IsNormalCleanupKind = 0x2,
150 F_IsEHCleanupKind = 0x4
188 typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
199 restore(CGF, llvm::index_sequence_for<As...>()).Emit(CGF, flags);
226 stable_iterator InnermostNormalCleanup;
229 stable_iterator InnermostEHScope;
250 char *allocate(
size_t Size);
256 StartOfData(nullptr), InnermostNormalCleanup(
stable_end()),
262 void *Buffer = pushCleanup(Kind,
sizeof(T));
263 Cleanup *Obj =
new (Buffer) T(A...);
268 template <
class T,
class... As>
270 void *Buffer = pushCleanup(Kind,
sizeof(T));
271 Cleanup *Obj =
new (Buffer) T(std::move(A));
288 template <
class T,
class... As>
290 void *Buffer = pushCleanup(Kind,
sizeof(T) + T::getExtraSize(N));
291 return new (Buffer) T(N, A...);
295 void *Buffer = pushCleanup(Kind, Size);
296 std::memcpy(Buffer, Cleanup, Size);
327 bool empty()
const {
return StartOfData == EndOfBuffer; }
335 return InnermostNormalCleanup !=
stable_end();
341 return InnermostNormalCleanup;
346 return InnermostEHScope;
356 iterator
begin()
const;
359 iterator
end()
const;
374 stable_iterator
stabilize(iterator it)
const;
378 iterator
find(stable_iterator save)
const;
387 return BranchFixups.back();
393 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()
static stable_iterator stable_end()
Create a stable reference to the bottom of the EH stack.
stable_iterator getInnermostActiveEHScope() const
static saved_type save(CodeGenFunction &CGF, type value)
T * pushCleanupWithExtra(CleanupKind Kind, size_t N, As...A)
void pushCleanupTuple(CleanupKind Kind, std::tuple< As...> A)
Push a lazily-created cleanup on the stack. Tuple version.
bool isForNormalCleanup() const
stable_iterator stabilize(iterator it) const
Translates an iterator into a stable_iterator.
class EHCatchScope * pushCatch(unsigned NumHandlers)
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...
void popFilter()
Pops an exceptions filter off the stack.
iterator find(stable_iterator save) const
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.
ConditionalCleanup(SavedTuple Tuple)
void removeCleanup(stable_iterator save)
Removes the cleanup pointed to by the given stable_iterator.
stable_iterator stable_begin() const
bool containsOnlyLifetimeMarkers(stable_iterator Old) const
void popCleanup()
Pops a cleanup scope off the stack. This is private to CGCleanup.cpp.
llvm::BasicBlock * OptimisticBranchBlock
void popCatch()
Pops a catch scope off the stack. This is private to CGException.cpp.
llvm::BasicBlock * Destination
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
friend bool operator==(stable_iterator A, stable_iterator B)
class EHFilterScope * pushFilter(unsigned NumFilters)
Push an exceptions filter on the stack.
bool encloses(stable_iterator I) const
BranchFixup & addBranchFixup()
Add a branch fixup to the current cleanup scope.
friend bool operator!=(stable_iterator A, stable_iterator B)
bool isEHCleanupKind() const
static stable_iterator invalid()
__PTRDIFF_TYPE__ ptrdiff_t
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
stable_iterator getInnermostNormalCleanup() const
bool isForEHCleanup() const
isForEH - true if the current emission is for an EH cleanup.
bool requiresLandingPad() const