Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:42

0001 //===-- EscapeEnumerator.h --------------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // Defines a helper class that enumerates all possible exits from a function,
0010 // including exception handling.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_TRANSFORMS_UTILS_ESCAPEENUMERATOR_H
0015 #define LLVM_TRANSFORMS_UTILS_ESCAPEENUMERATOR_H
0016 
0017 #include "llvm/IR/Function.h"
0018 #include "llvm/IR/IRBuilder.h"
0019 
0020 namespace llvm {
0021 
0022 class DomTreeUpdater;
0023 
0024 /// EscapeEnumerator - This is a little algorithm to find all escape points
0025 /// from a function so that "finally"-style code can be inserted. In addition
0026 /// to finding the existing return and unwind instructions, it also (if
0027 /// necessary) transforms any call instructions into invokes and sends them to
0028 /// a landing pad.
0029 class EscapeEnumerator {
0030   Function &F;
0031   const char *CleanupBBName;
0032 
0033   Function::iterator StateBB, StateE;
0034   IRBuilder<> Builder;
0035   bool Done = false;
0036   bool HandleExceptions;
0037 
0038   DomTreeUpdater *DTU;
0039 
0040 public:
0041   EscapeEnumerator(Function &F, const char *N = "cleanup",
0042                    bool HandleExceptions = true, DomTreeUpdater *DTU = nullptr)
0043       : F(F), CleanupBBName(N), StateBB(F.begin()), StateE(F.end()),
0044         Builder(F.getContext()), HandleExceptions(HandleExceptions), DTU(DTU) {}
0045 
0046   IRBuilder<> *Next();
0047 };
0048 
0049 }
0050 
0051 #endif // LLVM_TRANSFORMS_UTILS_ESCAPEENUMERATOR_H