1 //===-- EscapeEnumerator.h --------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Defines a helper class that enumerates all possible exits from a function,
11 // including exception handling.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TRANSFORMS_UTILS_ESCAPEENUMERATOR_H
16 #define LLVM_TRANSFORMS_UTILS_ESCAPEENUMERATOR_H
18 #include "llvm/IR/IRBuilder.h"
19 #include "llvm/IR/Function.h"
23 /// EscapeEnumerator - This is a little algorithm to find all escape points
24 /// from a function so that "finally"-style code can be inserted. In addition
25 /// to finding the existing return and unwind instructions, it also (if
26 /// necessary) transforms any call instructions into invokes and sends them to
28 class EscapeEnumerator {
30 const char *CleanupBBName;
32 Function::iterator StateBB, StateE;
35 bool HandleExceptions;
38 EscapeEnumerator(Function &F, const char *N = "cleanup",
39 bool HandleExceptions = true)
40 : F(F), CleanupBBName(N), StateBB(F.begin()), StateE(F.end()),
41 Builder(F.getContext()), Done(false),
42 HandleExceptions(HandleExceptions) {}
49 #endif // LLVM_TRANSFORMS_UTILS_ESCAPEENUMERATOR_H