/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/include/llvm/Transforms/Utils/EscapeEnumerator.h
Line | Count | Source |
1 | | //===-- EscapeEnumerator.h --------------------------------------*- C++ -*-===// |
2 | | // |
3 | | // The LLVM Compiler Infrastructure |
4 | | // |
5 | | // This file is distributed under the University of Illinois Open Source |
6 | | // License. See LICENSE.TXT for details. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | // |
10 | | // Defines a helper class that enumerates all possible exits from a function, |
11 | | // including exception handling. |
12 | | // |
13 | | //===----------------------------------------------------------------------===// |
14 | | |
15 | | #ifndef LLVM_TRANSFORMS_UTILS_ESCAPEENUMERATOR_H |
16 | | #define LLVM_TRANSFORMS_UTILS_ESCAPEENUMERATOR_H |
17 | | |
18 | | #include "llvm/IR/Function.h" |
19 | | #include "llvm/IR/IRBuilder.h" |
20 | | |
21 | | namespace llvm { |
22 | | |
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 |
27 | | /// a landing pad. |
28 | | class EscapeEnumerator { |
29 | | Function &F; |
30 | | const char *CleanupBBName; |
31 | | |
32 | | Function::iterator StateBB, StateE; |
33 | | IRBuilder<> Builder; |
34 | | bool Done; |
35 | | bool HandleExceptions; |
36 | | |
37 | | public: |
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 | 333 | HandleExceptions(HandleExceptions) {} |
43 | | |
44 | | IRBuilder<> *Next(); |
45 | | }; |
46 | | |
47 | | } |
48 | | |
49 | | #endif // LLVM_TRANSFORMS_UTILS_ESCAPEENUMERATOR_H |