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>
132 return A.Size == B.Size;
135 return A.Size != B.Size;
148 virtual void anchor();
170 F_IsNormalCleanupKind = 0x2,
171 F_IsEHCleanupKind = 0x4,
172 F_HasExitSwitch = 0x8,
207 template <
class T,
class... As>
209 typedef std::tuple<typename DominatingValue<As>::saved_type...> SavedTuple;
212 template <std::size_t... Is>
220 restore(CGF, std::index_sequence_for<As...>()).Emit(CGF, flags);
247 stable_iterator InnermostNormalCleanup;
250 stable_iterator InnermostEHScope;
274 char *allocate(
size_t Size);
275 void deallocate(
size_t Size);
281 : StartOfBuffer(nullptr), EndOfBuffer(nullptr), StartOfData(nullptr),
282 InnermostNormalCleanup(stable_end()), InnermostEHScope(stable_end()),
291 static_assert(
alignof(
T) <= ScopeStackAlignment,
292 "Cleanup's alignment is too large.");
293 void *Buffer = pushCleanup(
Kind,
sizeof(
T));
294 Cleanup *Obj =
new (Buffer)
T(A...);
299 template <
class T,
class... As>
301 static_assert(
alignof(
T) <= ScopeStackAlignment,
302 "Cleanup's alignment is too large.");
303 void *Buffer = pushCleanup(
Kind,
sizeof(
T));
304 Cleanup *Obj =
new (Buffer)
T(std::move(A));
321 template <
class T,
class... As>
323 static_assert(
alignof(
T) <= ScopeStackAlignment,
324 "Cleanup's alignment is too large.");
325 void *Buffer = pushCleanup(
Kind,
sizeof(
T) + T::getExtraSize(N));
326 return new (Buffer)
T(N, A...);
330 void *Buffer = pushCleanup(
Kind, Size);
331 std::memcpy(Buffer,
Cleanup, Size);
354 void pushTerminate();
361 bool containsOnlyNoopCleanups(stable_iterator Old)
const;
364 bool empty()
const {
return StartOfData == EndOfBuffer; }
366 bool requiresLandingPad()
const;
370 return InnermostNormalCleanup != stable_end();
376 return InnermostNormalCleanup;
378 stable_iterator getInnermostActiveNormalCleanup()
const;
381 return InnermostEHScope;
390 iterator begin()
const;
393 iterator end()
const;
408 stable_iterator stabilize(iterator it)
const;
412 iterator find(stable_iterator save)
const;
416 assert(hasNormalCleanups() &&
"adding fixup in scope without cleanups");
418 return BranchFixups.back();
423 assert(I < getNumBranchFixups());
424 return BranchFixups[I];
430 void popNullFixups();
enum clang::sema::@1840::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.
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
stable_iterator getInnermostEHScope() const
void pushCopyOfCleanup(CleanupKind Kind, const void *Cleanup, size_t Size)
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.
BranchFixup & addBranchFixup()
Add a branch fixup to the current cleanup scope.
bool hasNormalCleanups() const
Determines whether there are any normal cleanups on the stack.
static stable_iterator stable_end()
Create a stable reference to the bottom of the EH stack.
void clearFixups()
Clears the branch-fixups list.
EHScopeStack(const EHScopeStack &)=delete
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)