15#ifndef LLVM_CLANG_LIB_CODEGEN_EHSCOPESTACK_H
16#define LLVM_CLANG_LIB_CODEGEN_EHSCOPESTACK_H
19#include "llvm/ADT/STLExtras.h"
20#include "llvm/ADT/SmallVector.h"
21#include "llvm/IR/BasicBlock.h"
22#include "llvm/IR/Instructions.h"
23#include "llvm/IR/Value.h"
67template <
class T,
bool mightBeInstruction =
68 std::is_base_of<llvm::Value, T>::value &&
69 !std::is_base_of<llvm::Constant, T>::value &&
70 !std::is_base_of<llvm::BasicBlock, T>::value>
127 return A.Size == B.Size;
130 return A.Size != B.Size;
143 virtual void anchor();
165 F_IsNormalCleanupKind = 0x2,
166 F_IsEHCleanupKind = 0x4,
167 F_HasExitSwitch = 0x8,
202 template <
class T,
class... As>
204 typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
207 template <std::size_t... Is>
215 restore(CGF, std::index_sequence_for<As...>()).Emit(CGF, flags);
242 stable_iterator InnermostNormalCleanup;
245 stable_iterator InnermostEHScope;
269 char *allocate(
size_t Size);
270 void deallocate(
size_t Size);
276 : StartOfBuffer(nullptr), EndOfBuffer(nullptr), StartOfData(nullptr),
287 "Cleanup's alignment is too large.");
288 void *Buffer = pushCleanup(
Kind,
sizeof(
T));
289 Cleanup *Obj =
new (Buffer)
T(A...);
294 template <
class T,
class... As>
297 "Cleanup's alignment is too large.");
298 void *Buffer = pushCleanup(
Kind,
sizeof(
T));
299 Cleanup *Obj =
new (Buffer)
T(std::move(A));
316 template <
class T,
class... As>
319 "Cleanup's alignment is too large.");
320 void *Buffer = pushCleanup(
Kind,
sizeof(
T) + T::getExtraSize(N));
321 return new (Buffer)
T(N, A...);
325 void *Buffer = pushCleanup(
Kind, Size);
326 std::memcpy(Buffer,
Cleanup, Size);
359 bool empty()
const {
return StartOfData == EndOfBuffer; }
365 return InnermostNormalCleanup !=
stable_end();
371 return InnermostNormalCleanup;
376 return InnermostEHScope;
385 iterator
begin()
const;
388 iterator
end()
const;
403 stable_iterator
stabilize(iterator it)
const;
407 iterator
find(stable_iterator save)
const;
413 return BranchFixups.back();
419 return BranchFixups[I];
enum clang::sema::@1655::IndirectLocalPathEntry::EntryKind Kind
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
__PTRDIFF_TYPE__ ptrdiff_t
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
A scope which attempts to handle some, possibly all, types of exceptions.
An exceptions scope which filters exceptions thrown through it.
bool isEHCleanupKind() const
isEHCleanupKind - true if the cleanup was pushed as an EH cleanup.
bool hasExitSwitch() const
bool isForNormalCleanup() const
bool isNormalCleanupKind() const
void setIsNormalCleanupKind()
bool isForEHCleanup() const
isForEH - true if the current emission is for an EH cleanup.
void setIsEHCleanupKind()
Information for lazily generating a cleanup.
Cleanup & operator=(Cleanup &&)=delete
virtual void Emit(CodeGenFunction &CGF, Flags flags)=0
Emit the cleanup.
Cleanup(const Cleanup &)=default
Cleanup & operator=(const Cleanup &)=delete
virtual bool isRedundantBeforeReturn()
ConditionalCleanup stores the saved form of its parameters, then restores them and performs the clean...
ConditionalCleanup(SavedTuple Tuple)
ConditionalCleanup(typename DominatingValue< As >::saved_type... A)
A saved depth on the scope stack.
bool encloses(stable_iterator I) const
Returns true if this scope encloses I.
bool strictlyEncloses(stable_iterator I) const
Returns true if this scope strictly encloses I: that is, if it encloses I and is not I.
static stable_iterator invalid()
friend bool operator==(stable_iterator A, stable_iterator B)
friend bool operator!=(stable_iterator A, stable_iterator B)
A stack of scopes which respond to exceptions, including cleanups and catch blocks.
class EHFilterScope * pushFilter(unsigned NumFilters)
Push an exceptions filter on the stack.
BranchFixup & getBranchFixup(unsigned I)
stable_iterator getInnermostNormalCleanup() const
Returns the innermost normal cleanup on the stack, or stable_end() if there are no normal cleanups.
EHScopeStack & operator=(const EHScopeStack &)=delete
void setCGF(CodeGenFunction *inCGF)
stable_iterator stable_begin() const
Create a stable reference to the top of the EH stack.
unsigned getNumBranchFixups() const
void popCleanup()
Pops a cleanup scope off the stack. This is private to CGCleanup.cpp.
stable_iterator getInnermostEHScope() const
bool requiresLandingPad() const
void pushCopyOfCleanup(CleanupKind Kind, const void *Cleanup, size_t Size)
bool containsOnlyLifetimeMarkers(stable_iterator Old) const
bool empty() const
Determines whether the exception-scopes stack is empty.
void pushCleanup(CleanupKind Kind, As... A)
Push a lazily-created cleanup on the stack.
T * pushCleanupWithExtra(CleanupKind Kind, size_t N, As... A)
Push a cleanup with non-constant storage requirements on the stack.
iterator end() const
Returns an iterator pointing to the outermost EH scope.
void popFilter()
Pops an exceptions filter off the stack.
iterator begin() const
Returns an iterator pointing to the innermost EH scope.
BranchFixup & addBranchFixup()
Add a branch fixup to the current cleanup scope.
void popCatch()
Pops a catch scope off the stack. This is private to CGException.cpp.
class EHCatchScope * pushCatch(unsigned NumHandlers)
Push a set of catch handlers on the stack.
iterator find(stable_iterator save) const
Turn a stable reference to a scope depth into a unstable pointer to the EH stack.
void popNullFixups()
Pops lazily-removed fixups from the end of the list.
bool hasNormalCleanups() const
Determines whether there are any normal cleanups on the stack.
stable_iterator getInnermostActiveNormalCleanup() const
stable_iterator stabilize(iterator it) const
Translates an iterator into a stable_iterator.
static stable_iterator stable_end()
Create a stable reference to the bottom of the EH stack.
void clearFixups()
Clears the branch-fixups list.
void popTerminate()
Pops a terminate handler off the stack.
EHScopeStack(const EHScopeStack &)=delete
void pushTerminate()
Push a terminate handler on the stack.
void pushCleanupTuple(CleanupKind Kind, std::tuple< As... > A)
Push a lazily-created cleanup on the stack. Tuple version.
@ NormalCleanup
Denotes a cleanup that should run when a scope is exited using normal control flow (falling off the e...
@ EHCleanup
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
unsigned DestinationIndex
The destination index value.
llvm::BasicBlock * Destination
The ultimate destination of the branch.
llvm::BasicBlock * OptimisticBranchBlock
The block containing the terminator which needs to be modified into a switch if this fixup is resolve...
llvm::BranchInst * InitialBranch
The initial branch of the fixup.
A metaprogramming class for ensuring that a value will dominate an arbitrary position in a function.
static bool needsSaving(type value)
static type restore(CodeGenFunction &CGF, saved_type value)
static saved_type save(CodeGenFunction &CGF, type value)