1//===----------------------------------------------------------------------===//
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#include "llvm/DWARFCFIChecker/DWARFCFIFunctionFrameAnalyzer.h"
10
11using namespace llvm;
12
13CFIFunctionFrameAnalyzer::~CFIFunctionFrameAnalyzer() {
14 assert(UIAs.empty() &&
15 "all frames should be closed before the analysis finishes");
16}
17
18void CFIFunctionFrameAnalyzer::startFunctionFrame(
19 bool IsEH, ArrayRef<MCCFIInstruction> Prologue) {
20 UIAs.emplace_back(Args: &getContext(), Args: MCII, Args&: IsEH, Args&: Prologue);
21}
22
23void CFIFunctionFrameAnalyzer::emitInstructionAndDirectives(
24 const MCInst &Inst, ArrayRef<MCCFIInstruction> Directives) {
25 assert(!UIAs.empty() && "if the instruction is in a frame, there should be "
26 "a analysis instantiated for it");
27 UIAs.back().update(Inst, Directives);
28}
29
30void CFIFunctionFrameAnalyzer::finishFunctionFrame() {
31 assert(!UIAs.empty() && "there should be an analysis for each frame");
32 UIAs.pop_back();
33}
34