llvm/clang/lib/CodeGen/CGException.cpp

//===--- CGException.cpp - Emit LLVM Code for C++ exceptions ----*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This contains code dealing with C++ exception related code generation.
//
//===----------------------------------------------------------------------===//

#include "CGCXXABI.h"
#include "CGCleanup.h"
#include "CGObjCRuntime.h"
#include "CodeGenFunction.h"
#include "ConstantEmitter.h"
#include "TargetInfo.h"
#include "clang/AST/Mangle.h"
#include "clang/AST/StmtCXX.h"
#include "clang/AST/StmtObjC.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/DiagnosticSema.h"
#include "clang/Basic/TargetBuiltins.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/IntrinsicsWebAssembly.h"
#include "llvm/Support/SaveAndRestore.h"

usingnamespaceclang;
usingnamespaceCodeGen;

static llvm::FunctionCallee getFreeExceptionFn(CodeGenModule &CGM) {}

static llvm::FunctionCallee getSehTryBeginFn(CodeGenModule &CGM) {}

static llvm::FunctionCallee getSehTryEndFn(CodeGenModule &CGM) {}

static llvm::FunctionCallee getUnexpectedFn(CodeGenModule &CGM) {}

llvm::FunctionCallee CodeGenModule::getTerminateFn() {}

static llvm::FunctionCallee getCatchallRethrowFn(CodeGenModule &CGM,
                                                 StringRef Name) {}

const EHPersonality EHPersonality::GNU_C =;
const EHPersonality
EHPersonality::GNU_C_SJLJ =;
const EHPersonality
EHPersonality::GNU_C_SEH =;
const EHPersonality
EHPersonality::NeXT_ObjC =;
const EHPersonality
EHPersonality::GNU_CPlusPlus =;
const EHPersonality
EHPersonality::GNU_CPlusPlus_SJLJ =;
const EHPersonality
EHPersonality::GNU_CPlusPlus_SEH =;
const EHPersonality
EHPersonality::GNU_ObjC =;
const EHPersonality
EHPersonality::GNU_ObjC_SJLJ =;
const EHPersonality
EHPersonality::GNU_ObjC_SEH =;
const EHPersonality
EHPersonality::GNU_ObjCXX =;
const EHPersonality
EHPersonality::GNUstep_ObjC =;
const EHPersonality
EHPersonality::MSVC_except_handler =;
const EHPersonality
EHPersonality::MSVC_C_specific_handler =;
const EHPersonality
EHPersonality::MSVC_CxxFrameHandler3 =;
const EHPersonality
EHPersonality::GNU_Wasm_CPlusPlus =;
const EHPersonality EHPersonality::XL_CPlusPlus =;
const EHPersonality EHPersonality::ZOS_CPlusPlus =;

static const EHPersonality &getCPersonality(const TargetInfo &Target,
                                            const LangOptions &L) {}

static const EHPersonality &getObjCPersonality(const TargetInfo &Target,
                                               const LangOptions &L) {}

static const EHPersonality &getCXXPersonality(const TargetInfo &Target,
                                              const LangOptions &L) {}

/// Determines the personality function to use when both C++
/// and Objective-C exceptions are being caught.
static const EHPersonality &getObjCXXPersonality(const TargetInfo &Target,
                                                 const LangOptions &L) {}

static const EHPersonality &getSEHPersonalityMSVC(const llvm::Triple &T) {}

const EHPersonality &EHPersonality::get(CodeGenModule &CGM,
                                        const FunctionDecl *FD) {}

const EHPersonality &EHPersonality::get(CodeGenFunction &CGF) {}

static llvm::FunctionCallee getPersonalityFn(CodeGenModule &CGM,
                                             const EHPersonality &Personality) {}

static llvm::Constant *getOpaquePersonalityFn(CodeGenModule &CGM,
                                        const EHPersonality &Personality) {}

/// Check whether a landingpad instruction only uses C++ features.
static bool LandingPadHasOnlyCXXUses(llvm::LandingPadInst *LPI) {}

/// Check whether a personality function could reasonably be swapped
/// for a C++ personality function.
static bool PersonalityHasOnlyCXXUses(llvm::Constant *Fn) {}

/// Try to use the C++ personality function in ObjC++.  Not doing this
/// can cause some incompatibilities with gcc, which is more
/// aggressive about only using the ObjC++ personality in a function
/// when it really needs it.
void CodeGenModule::SimplifyPersonality() {}

/// Returns the value to inject into a selector to indicate the
/// presence of a catch-all.
static llvm::Constant *getCatchAllValue(CodeGenFunction &CGF) {}

namespace {
  /// A cleanup to free the exception object if its initialization
  /// throws.
  struct FreeException final : EHScopeStack::Cleanup {};
} // end anonymous namespace

// Emits an exception expression into the given location.  This
// differs from EmitAnyExprToMem only in that, if a final copy-ctor
// call is required, an exception within that copy ctor causes
// std::terminate to be invoked.
void CodeGenFunction::EmitAnyExprToExn(const Expr *e, Address addr) {}

Address CodeGenFunction::getExceptionSlot() {}

Address CodeGenFunction::getEHSelectorSlot() {}

llvm::Value *CodeGenFunction::getExceptionFromSlot() {}

llvm::Value *CodeGenFunction::getSelectorFromSlot() {}

void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E,
                                       bool KeepInsertionPoint) {}

void CodeGenFunction::EmitStartEHSpec(const Decl *D) {}

/// Emit the dispatch block for a filter scope if necessary.
static void emitFilterDispatchBlock(CodeGenFunction &CGF,
                                    EHFilterScope &filterScope) {}

void CodeGenFunction::EmitEndEHSpec(const Decl *D) {}

void CodeGenFunction::EmitCXXTryStmt(const CXXTryStmt &S) {}

void CodeGenFunction::EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock) {}

llvm::BasicBlock *
CodeGenFunction::getEHDispatchBlock(EHScopeStack::stable_iterator si) {}

llvm::BasicBlock *
CodeGenFunction::getFuncletEHDispatchBlock(EHScopeStack::stable_iterator SI) {}

/// Check whether this is a non-EH scope, i.e. a scope which doesn't
/// affect exception handling.  Currently, the only non-EH scopes are
/// normal-only cleanup scopes.
static bool isNonEHScope(const EHScope &S) {}

llvm::BasicBlock *CodeGenFunction::getInvokeDestImpl() {}

llvm::BasicBlock *CodeGenFunction::EmitLandingPad() {}

static void emitCatchPadBlock(CodeGenFunction &CGF, EHCatchScope &CatchScope) {}

// Wasm uses Windows-style EH instructions, but it merges all catch clauses into
// one big catchpad, within which we use Itanium's landingpad-style selector
// comparison instructions.
static void emitWasmCatchPadBlock(CodeGenFunction &CGF,
                                  EHCatchScope &CatchScope) {}

/// Emit the structure of the dispatch block for the given catch scope.
/// It is an invariant that the dispatch block already exists.
static void emitCatchDispatchBlock(CodeGenFunction &CGF,
                                   EHCatchScope &catchScope) {}

void CodeGenFunction::popCatchScope() {}

void CodeGenFunction::ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock) {}

namespace {
  struct CallEndCatchForFinally final : EHScopeStack::Cleanup {};

  struct PerformFinally final : EHScopeStack::Cleanup {};
} // end anonymous namespace

/// Enters a finally block for an implementation using zero-cost
/// exceptions.  This is mostly general, but hard-codes some
/// language/ABI-specific behavior in the catch-all sections.
void CodeGenFunction::FinallyInfo::enter(CodeGenFunction &CGF, const Stmt *body,
                                         llvm::FunctionCallee beginCatchFn,
                                         llvm::FunctionCallee endCatchFn,
                                         llvm::FunctionCallee rethrowFn) {}

void CodeGenFunction::FinallyInfo::exit(CodeGenFunction &CGF) {}

llvm::BasicBlock *CodeGenFunction::getTerminateLandingPad() {}

llvm::BasicBlock *CodeGenFunction::getTerminateHandler() {}

llvm::BasicBlock *CodeGenFunction::getTerminateFunclet() {}

llvm::BasicBlock *CodeGenFunction::getEHResumeBlock(bool isCleanup) {}

void CodeGenFunction::EmitSEHTryStmt(const SEHTryStmt &S) {}

//  Recursively walk through blocks in a _try
//      and make all memory instructions volatile
void CodeGenFunction::VolatilizeTryBlocks(
    llvm::BasicBlock *BB, llvm::SmallPtrSet<llvm::BasicBlock *, 10> &V) {}

namespace {
struct PerformSEHFinally final : EHScopeStack::Cleanup {};
} // end anonymous namespace

namespace {
/// Find all local variable captures in the statement.
struct CaptureFinder : ConstStmtVisitor<CaptureFinder> {};
} // end anonymous namespace

Address CodeGenFunction::recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF,
                                                   Address ParentVar,
                                                   llvm::Value *ParentFP) {}

void CodeGenFunction::EmitCapturedLocals(CodeGenFunction &ParentCGF,
                                         const Stmt *OutlinedStmt,
                                         bool IsFilter) {}

/// Arrange a function prototype that can be called by Windows exception
/// handling personalities. On Win64, the prototype looks like:
/// RetTy func(void *EHPtrs, void *ParentFP);
void CodeGenFunction::startOutlinedSEHHelper(CodeGenFunction &ParentCGF,
                                             bool IsFilter,
                                             const Stmt *OutlinedStmt) {}

/// Create a stub filter function that will ultimately hold the code of the
/// filter expression. The EH preparation passes in LLVM will outline the code
/// from the main function body into this stub.
llvm::Function *
CodeGenFunction::GenerateSEHFilterFunction(CodeGenFunction &ParentCGF,
                                           const SEHExceptStmt &Except) {}

llvm::Function *
CodeGenFunction::GenerateSEHFinallyFunction(CodeGenFunction &ParentCGF,
                                            const SEHFinallyStmt &Finally) {}

void CodeGenFunction::EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF,
                                               llvm::Value *ParentFP,
                                               llvm::Value *EntryFP) {}

llvm::Value *CodeGenFunction::EmitSEHExceptionInfo() {}

llvm::Value *CodeGenFunction::EmitSEHExceptionCode() {}

llvm::Value *CodeGenFunction::EmitSEHAbnormalTermination() {}

void CodeGenFunction::pushSEHCleanup(CleanupKind Kind,
                                     llvm::Function *FinallyFunc) {}

void CodeGenFunction::EnterSEHTryStmt(const SEHTryStmt &S) {}

void CodeGenFunction::ExitSEHTryStmt(const SEHTryStmt &S) {}

void CodeGenFunction::EmitSEHLeaveStmt(const SEHLeaveStmt &S) {}