Path: blob/main/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DebugLocStream.cpp
35271 views
//===- DebugLocStream.cpp - DWARF debug_loc stream --------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "DebugLocStream.h"9#include "DwarfDebug.h"10#include "llvm/CodeGen/AsmPrinter.h"1112using namespace llvm;1314bool DebugLocStream::finalizeList(AsmPrinter &Asm) {15if (Lists.back().EntryOffset == Entries.size()) {16// Empty list. Delete it.17Lists.pop_back();18return false;19}2021// Real list. Generate a label for it.22Lists.back().Label = Asm.createTempSymbol("debug_loc");23return true;24}2526void DebugLocStream::finalizeEntry() {27if (Entries.back().ByteOffset != DWARFBytes.size())28return;2930// The last entry was empty. Delete it.31Comments.erase(Comments.begin() + Entries.back().CommentOffset,32Comments.end());33Entries.pop_back();3435assert(Lists.back().EntryOffset <= Entries.size() &&36"Popped off more entries than are in the list");37}3839DebugLocStream::ListBuilder::~ListBuilder() {40if (!Locs.finalizeList(Asm))41return;42V.emplace<Loc::Multi>(ListIndex, TagOffset);43}444546