| Duncan P. N. Exon Smith | 3a73d9e | 2015-06-21 16:54:56 +0000 | [diff] [blame] | 1 | //===- DebugLocStream.cpp - DWARF debug_loc stream --------------*- C++ -*-===// | 
|  | 2 | // | 
| Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 | 
| Duncan P. N. Exon Smith | 3a73d9e | 2015-06-21 16:54:56 +0000 | [diff] [blame] | 6 | // | 
|  | 7 | //===----------------------------------------------------------------------===// | 
|  | 8 |  | 
|  | 9 | #include "DebugLocStream.h" | 
|  | 10 | #include "DwarfDebug.h" | 
|  | 11 | #include "llvm/CodeGen/AsmPrinter.h" | 
|  | 12 |  | 
|  | 13 | using namespace llvm; | 
|  | 14 |  | 
|  | 15 | bool DebugLocStream::finalizeList(AsmPrinter &Asm) { | 
|  | 16 | if (Lists.back().EntryOffset == Entries.size()) { | 
|  | 17 | // Empty list.  Delete it. | 
|  | 18 | Lists.pop_back(); | 
|  | 19 | return false; | 
|  | 20 | } | 
|  | 21 |  | 
|  | 22 | // Real list.  Generate a label for it. | 
|  | 23 | Lists.back().Label = Asm.createTempSymbol("debug_loc"); | 
|  | 24 | return true; | 
|  | 25 | } | 
|  | 26 |  | 
|  | 27 | void DebugLocStream::finalizeEntry() { | 
|  | 28 | if (Entries.back().ByteOffset != DWARFBytes.size()) | 
|  | 29 | return; | 
|  | 30 |  | 
|  | 31 | // The last entry was empty.  Delete it. | 
|  | 32 | Comments.erase(Comments.begin() + Entries.back().CommentOffset, | 
|  | 33 | Comments.end()); | 
|  | 34 | Entries.pop_back(); | 
|  | 35 |  | 
|  | 36 | assert(Lists.back().EntryOffset <= Entries.size() && | 
|  | 37 | "Popped off more entries than are in the list"); | 
|  | 38 | } | 
|  | 39 |  | 
|  | 40 | DebugLocStream::ListBuilder::~ListBuilder() { | 
|  | 41 | if (!Locs.finalizeList(Asm)) | 
|  | 42 | return; | 
|  | 43 | V.initializeDbgValue(&MI); | 
|  | 44 | V.setDebugLocListIndex(ListIndex); | 
|  | 45 | } |