LLVM  9.0.0svn
EscapeEnumerator.h
Go to the documentation of this file.
1 //===-- EscapeEnumerator.h --------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Defines a helper class that enumerates all possible exits from a function,
10 // including exception handling.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_TRANSFORMS_UTILS_ESCAPEENUMERATOR_H
15 #define LLVM_TRANSFORMS_UTILS_ESCAPEENUMERATOR_H
16 
17 #include "llvm/IR/Function.h"
18 #include "llvm/IR/IRBuilder.h"
19 
20 namespace llvm {
21 
22 /// EscapeEnumerator - This is a little algorithm to find all escape points
23 /// from a function so that "finally"-style code can be inserted. In addition
24 /// to finding the existing return and unwind instructions, it also (if
25 /// necessary) transforms any call instructions into invokes and sends them to
26 /// a landing pad.
28  Function &F;
29  const char *CleanupBBName;
30 
31  Function::iterator StateBB, StateE;
32  IRBuilder<> Builder;
33  bool Done;
34  bool HandleExceptions;
35 
36 public:
37  EscapeEnumerator(Function &F, const char *N = "cleanup",
38  bool HandleExceptions = true)
39  : F(F), CleanupBBName(N), StateBB(F.begin()), StateE(F.end()),
40  Builder(F.getContext()), Done(false),
41  HandleExceptions(HandleExceptions) {}
42 
43  IRBuilder<> *Next();
44 };
45 
46 }
47 
48 #endif // LLVM_TRANSFORMS_UTILS_ESCAPEENUMERATOR_H
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:233
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:224
This class represents lattice values for constants.
Definition: AllocatorList.h:23
EscapeEnumerator - This is a little algorithm to find all escape points from a function so that "fina...
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition: IRBuilder.h:779
EscapeEnumerator(Function &F, const char *N="cleanup", bool HandleExceptions=true)
Iterator for intrusive lists based on ilist_node.
#define N