Devang Patel | 8dfb655 | 2011-10-04 17:24:48 +0000 | [diff] [blame] | 1 | //===- GCOVr.cpp - LLVM coverage tool -------------------------------------===// |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Devang Patel | 8dfb655 | 2011-10-04 17:24:48 +0000 | [diff] [blame] | 10 | // GCOV implements the interface to read and write coverage files that use |
| 11 | // 'gcov' format. |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 12 | // |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Yuchen Wu | 0367815 | 2013-10-25 02:22:24 +0000 | [diff] [blame] | 15 | #include "llvm/Support/Debug.h" |
Devang Patel | 8dfb655 | 2011-10-04 17:24:48 +0000 | [diff] [blame] | 16 | #include "llvm/Support/GCOV.h" |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/OwningPtr.h" |
Devang Patel | a9e8a25 | 2011-09-29 16:46:47 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/STLExtras.h" |
Bob Wilson | 3461bed | 2013-10-22 05:09:41 +0000 | [diff] [blame] | 19 | #include "llvm/Support/Format.h" |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 20 | #include "llvm/Support/MemoryObject.h" |
| 21 | #include "llvm/Support/system_error.h" |
| 22 | using namespace llvm; |
| 23 | |
| 24 | //===----------------------------------------------------------------------===// |
| 25 | // GCOVFile implementation. |
| 26 | |
| 27 | /// ~GCOVFile - Delete GCOVFile and its content. |
| 28 | GCOVFile::~GCOVFile() { |
| 29 | DeleteContainerPointers(Functions); |
| 30 | } |
| 31 | |
Devang Patel | e5a8f2f9 | 2011-09-29 17:06:40 +0000 | [diff] [blame] | 32 | /// isGCDAFile - Return true if Format identifies a .gcda file. |
Bill Wendling | 6bbe489 | 2012-08-31 17:31:28 +0000 | [diff] [blame] | 33 | static bool isGCDAFile(GCOV::GCOVFormat Format) { |
| 34 | return Format == GCOV::GCDA_402 || Format == GCOV::GCDA_404; |
Devang Patel | e5a8f2f9 | 2011-09-29 17:06:40 +0000 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | /// isGCNOFile - Return true if Format identifies a .gcno file. |
Bill Wendling | 6bbe489 | 2012-08-31 17:31:28 +0000 | [diff] [blame] | 38 | static bool isGCNOFile(GCOV::GCOVFormat Format) { |
| 39 | return Format == GCOV::GCNO_402 || Format == GCOV::GCNO_404; |
Devang Patel | e5a8f2f9 | 2011-09-29 17:06:40 +0000 | [diff] [blame] | 40 | } |
| 41 | |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 42 | /// read - Read GCOV buffer. |
| 43 | bool GCOVFile::read(GCOVBuffer &Buffer) { |
Bill Wendling | 6bbe489 | 2012-08-31 17:31:28 +0000 | [diff] [blame] | 44 | GCOV::GCOVFormat Format = Buffer.readGCOVFormat(); |
| 45 | if (Format == GCOV::InvalidGCOV) |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 46 | return false; |
| 47 | |
Yuchen Wu | 14ae8e6 | 2013-10-25 02:22:21 +0000 | [diff] [blame] | 48 | if (isGCNOFile(Format)) { |
| 49 | while (true) { |
| 50 | GCOVFunction *GFun = new GCOVFunction(); |
| 51 | if (!GFun->read(Buffer, Format)) |
| 52 | break; |
Devang Patel | e5a8f2f9 | 2011-09-29 17:06:40 +0000 | [diff] [blame] | 53 | Functions.push_back(GFun); |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 54 | } |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 55 | } |
Yuchen Wu | 14ae8e6 | 2013-10-25 02:22:21 +0000 | [diff] [blame] | 56 | else if (isGCDAFile(Format)) { |
| 57 | for (size_t i = 0, e = Functions.size(); i < e; ++i) { |
| 58 | bool ReadGCDA = Functions[i]->read(Buffer, Format); |
| 59 | (void)ReadGCDA; |
| 60 | assert(ReadGCDA && ".gcda data does not match .gcno data"); |
| 61 | } |
| 62 | while (Buffer.readProgramTag()) |
| 63 | ++ProgramCount; |
| 64 | } |
| 65 | |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 66 | return true; |
| 67 | } |
| 68 | |
Yuchen Wu | 0367815 | 2013-10-25 02:22:24 +0000 | [diff] [blame] | 69 | /// dump - Dump GCOVFile content to dbgs() for debugging purposes. |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 70 | void GCOVFile::dump() { |
Craig Topper | af0dea1 | 2013-07-04 01:31:24 +0000 | [diff] [blame] | 71 | for (SmallVectorImpl<GCOVFunction *>::iterator I = Functions.begin(), |
Bill Wendling | ea6397f | 2012-07-19 00:11:40 +0000 | [diff] [blame] | 72 | E = Functions.end(); I != E; ++I) |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 73 | (*I)->dump(); |
| 74 | } |
| 75 | |
| 76 | /// collectLineCounts - Collect line counts. This must be used after |
| 77 | /// reading .gcno and .gcda files. |
| 78 | void GCOVFile::collectLineCounts(FileInfo &FI) { |
Craig Topper | af0dea1 | 2013-07-04 01:31:24 +0000 | [diff] [blame] | 79 | for (SmallVectorImpl<GCOVFunction *>::iterator I = Functions.begin(), |
Bill Wendling | ea6397f | 2012-07-19 00:11:40 +0000 | [diff] [blame] | 80 | E = Functions.end(); I != E; ++I) |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 81 | (*I)->collectLineCounts(FI); |
Yuchen Wu | 14ae8e6 | 2013-10-25 02:22:21 +0000 | [diff] [blame] | 82 | FI.setProgramCount(ProgramCount); |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | //===----------------------------------------------------------------------===// |
| 86 | // GCOVFunction implementation. |
| 87 | |
| 88 | /// ~GCOVFunction - Delete GCOVFunction and its content. |
| 89 | GCOVFunction::~GCOVFunction() { |
| 90 | DeleteContainerPointers(Blocks); |
| 91 | } |
| 92 | |
Bob Wilson | 00928bc | 2013-10-22 19:54:32 +0000 | [diff] [blame] | 93 | /// read - Read a function from the buffer. Return false if buffer cursor |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 94 | /// does not point to a function tag. |
Bill Wendling | 6bbe489 | 2012-08-31 17:31:28 +0000 | [diff] [blame] | 95 | bool GCOVFunction::read(GCOVBuffer &Buff, GCOV::GCOVFormat Format) { |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 96 | if (!Buff.readFunctionTag()) |
| 97 | return false; |
| 98 | |
| 99 | Buff.readInt(); // Function header length |
| 100 | Ident = Buff.readInt(); |
| 101 | Buff.readInt(); // Checksum #1 |
Bill Wendling | c432503 | 2013-06-25 18:13:52 +0000 | [diff] [blame] | 102 | if (Format != GCOV::GCNO_402 && Format != GCOV::GCDA_402) |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 103 | Buff.readInt(); // Checksum #2 |
| 104 | |
| 105 | Name = Buff.readString(); |
Bill Wendling | 6bbe489 | 2012-08-31 17:31:28 +0000 | [diff] [blame] | 106 | if (Format == GCOV::GCNO_402 || Format == GCOV::GCNO_404) |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 107 | Filename = Buff.readString(); |
| 108 | |
Bill Wendling | 6bbe489 | 2012-08-31 17:31:28 +0000 | [diff] [blame] | 109 | if (Format == GCOV::GCDA_402 || Format == GCOV::GCDA_404) { |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 110 | Buff.readArcTag(); |
Yuchen Wu | 887c20f | 2013-10-24 01:51:04 +0000 | [diff] [blame] | 111 | uint32_t i = 0; |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 112 | uint32_t Count = Buff.readInt() / 2; |
Yuchen Wu | 887c20f | 2013-10-24 01:51:04 +0000 | [diff] [blame] | 113 | |
| 114 | // This for loop adds the counts for each block. A second nested loop is |
| 115 | // required to combine the edge counts that are contained in the GCDA file. |
| 116 | for (uint32_t Line = 0; i < Count; ++Line) { |
| 117 | GCOVBlock &Block = *Blocks[Line]; |
| 118 | for (size_t Edge = 0, End = Block.getNumEdges(); Edge < End; ++Edge) { |
| 119 | assert(i < Count && "Unexpected number of Edges!"); |
| 120 | Block.addCount(Buff.readInt64()); |
| 121 | ++i; |
| 122 | } |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 123 | } |
Chad Rosier | 5dfe6da | 2012-02-22 17:25:00 +0000 | [diff] [blame] | 124 | return true; |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | LineNumber = Buff.readInt(); |
| 128 | |
| 129 | // read blocks. |
Nick Lewycky | c6b4f03 | 2012-09-23 03:58:21 +0000 | [diff] [blame] | 130 | bool BlockTagFound = Buff.readBlockTag(); |
| 131 | (void)BlockTagFound; |
| 132 | assert(BlockTagFound && "Block Tag not found!"); |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 133 | uint32_t BlockCount = Buff.readInt(); |
Bob Wilson | 868e6e3 | 2013-10-22 20:02:36 +0000 | [diff] [blame] | 134 | for (uint32_t i = 0, e = BlockCount; i != e; ++i) { |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 135 | Buff.readInt(); // Block flags; |
| 136 | Blocks.push_back(new GCOVBlock(i)); |
| 137 | } |
| 138 | |
| 139 | // read edges. |
| 140 | while (Buff.readEdgeTag()) { |
| 141 | uint32_t EdgeCount = (Buff.readInt() - 1) / 2; |
| 142 | uint32_t BlockNo = Buff.readInt(); |
Nick Lewycky | c6b4f03 | 2012-09-23 03:58:21 +0000 | [diff] [blame] | 143 | assert(BlockNo < BlockCount && "Unexpected Block number!"); |
Bob Wilson | 868e6e3 | 2013-10-22 20:02:36 +0000 | [diff] [blame] | 144 | for (uint32_t i = 0, e = EdgeCount; i != e; ++i) { |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 145 | Blocks[BlockNo]->addEdge(Buff.readInt()); |
| 146 | Buff.readInt(); // Edge flag |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | // read line table. |
| 151 | while (Buff.readLineTag()) { |
| 152 | uint32_t LineTableLength = Buff.readInt(); |
Bob Wilson | 00928bc | 2013-10-22 19:54:32 +0000 | [diff] [blame] | 153 | uint32_t EndPos = Buff.getCursor() + LineTableLength*4; |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 154 | uint32_t BlockNo = Buff.readInt(); |
Nick Lewycky | c6b4f03 | 2012-09-23 03:58:21 +0000 | [diff] [blame] | 155 | assert(BlockNo < BlockCount && "Unexpected Block number!"); |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 156 | GCOVBlock *Block = Blocks[BlockNo]; |
| 157 | Buff.readInt(); // flag |
Bob Wilson | 00928bc | 2013-10-22 19:54:32 +0000 | [diff] [blame] | 158 | while (Buff.getCursor() != (EndPos - 4)) { |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 159 | StringRef Filename = Buff.readString(); |
Bob Wilson | 00928bc | 2013-10-22 19:54:32 +0000 | [diff] [blame] | 160 | if (Buff.getCursor() == (EndPos - 4)) break; |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 161 | while (uint32_t L = Buff.readInt()) |
Bill Wendling | ea6397f | 2012-07-19 00:11:40 +0000 | [diff] [blame] | 162 | Block->addLine(Filename, L); |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 163 | } |
| 164 | Buff.readInt(); // flag |
| 165 | } |
| 166 | return true; |
| 167 | } |
| 168 | |
Yuchen Wu | 0367815 | 2013-10-25 02:22:24 +0000 | [diff] [blame] | 169 | /// dump - Dump GCOVFunction content to dbgs() for debugging purposes. |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 170 | void GCOVFunction::dump() { |
Yuchen Wu | 0367815 | 2013-10-25 02:22:24 +0000 | [diff] [blame] | 171 | dbgs() << "===== " << Name << " @ " << Filename << ":" << LineNumber << "\n"; |
Craig Topper | af0dea1 | 2013-07-04 01:31:24 +0000 | [diff] [blame] | 172 | for (SmallVectorImpl<GCOVBlock *>::iterator I = Blocks.begin(), |
Bill Wendling | ea6397f | 2012-07-19 00:11:40 +0000 | [diff] [blame] | 173 | E = Blocks.end(); I != E; ++I) |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 174 | (*I)->dump(); |
| 175 | } |
| 176 | |
| 177 | /// collectLineCounts - Collect line counts. This must be used after |
| 178 | /// reading .gcno and .gcda files. |
| 179 | void GCOVFunction::collectLineCounts(FileInfo &FI) { |
Craig Topper | af0dea1 | 2013-07-04 01:31:24 +0000 | [diff] [blame] | 180 | for (SmallVectorImpl<GCOVBlock *>::iterator I = Blocks.begin(), |
Bill Wendling | ea6397f | 2012-07-19 00:11:40 +0000 | [diff] [blame] | 181 | E = Blocks.end(); I != E; ++I) |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 182 | (*I)->collectLineCounts(FI); |
| 183 | } |
| 184 | |
| 185 | //===----------------------------------------------------------------------===// |
| 186 | // GCOVBlock implementation. |
| 187 | |
| 188 | /// ~GCOVBlock - Delete GCOVBlock and its content. |
| 189 | GCOVBlock::~GCOVBlock() { |
| 190 | Edges.clear(); |
| 191 | DeleteContainerSeconds(Lines); |
| 192 | } |
| 193 | |
| 194 | void GCOVBlock::addLine(StringRef Filename, uint32_t LineNo) { |
| 195 | GCOVLines *&LinesForFile = Lines[Filename]; |
| 196 | if (!LinesForFile) |
| 197 | LinesForFile = new GCOVLines(); |
| 198 | LinesForFile->add(LineNo); |
| 199 | } |
| 200 | |
| 201 | /// collectLineCounts - Collect line counts. This must be used after |
| 202 | /// reading .gcno and .gcda files. |
| 203 | void GCOVBlock::collectLineCounts(FileInfo &FI) { |
| 204 | for (StringMap<GCOVLines *>::iterator I = Lines.begin(), |
Bill Wendling | ea6397f | 2012-07-19 00:11:40 +0000 | [diff] [blame] | 205 | E = Lines.end(); I != E; ++I) |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 206 | I->second->collectLineCounts(FI, I->first(), Counter); |
| 207 | } |
| 208 | |
Yuchen Wu | 0367815 | 2013-10-25 02:22:24 +0000 | [diff] [blame] | 209 | /// dump - Dump GCOVBlock content to dbgs() for debugging purposes. |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 210 | void GCOVBlock::dump() { |
Yuchen Wu | 0367815 | 2013-10-25 02:22:24 +0000 | [diff] [blame] | 211 | dbgs() << "Block : " << Number << " Counter : " << Counter << "\n"; |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 212 | if (!Edges.empty()) { |
Yuchen Wu | 0367815 | 2013-10-25 02:22:24 +0000 | [diff] [blame] | 213 | dbgs() << "\tEdges : "; |
Craig Topper | af0dea1 | 2013-07-04 01:31:24 +0000 | [diff] [blame] | 214 | for (SmallVectorImpl<uint32_t>::iterator I = Edges.begin(), E = Edges.end(); |
Bill Wendling | ea6397f | 2012-07-19 00:11:40 +0000 | [diff] [blame] | 215 | I != E; ++I) |
Yuchen Wu | 0367815 | 2013-10-25 02:22:24 +0000 | [diff] [blame] | 216 | dbgs() << (*I) << ","; |
| 217 | dbgs() << "\n"; |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 218 | } |
| 219 | if (!Lines.empty()) { |
Yuchen Wu | 0367815 | 2013-10-25 02:22:24 +0000 | [diff] [blame] | 220 | dbgs() << "\tLines : "; |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 221 | for (StringMap<GCOVLines *>::iterator LI = Lines.begin(), |
Bill Wendling | ea6397f | 2012-07-19 00:11:40 +0000 | [diff] [blame] | 222 | LE = Lines.end(); LI != LE; ++LI) { |
Yuchen Wu | 0367815 | 2013-10-25 02:22:24 +0000 | [diff] [blame] | 223 | dbgs() << LI->first() << " -> "; |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 224 | LI->second->dump(); |
Yuchen Wu | 0367815 | 2013-10-25 02:22:24 +0000 | [diff] [blame] | 225 | dbgs() << "\n"; |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 226 | } |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | //===----------------------------------------------------------------------===// |
| 231 | // GCOVLines implementation. |
| 232 | |
| 233 | /// collectLineCounts - Collect line counts. This must be used after |
| 234 | /// reading .gcno and .gcda files. |
| 235 | void GCOVLines::collectLineCounts(FileInfo &FI, StringRef Filename, |
Bob Wilson | 68bf30a | 2013-10-22 17:43:47 +0000 | [diff] [blame] | 236 | uint64_t Count) { |
Craig Topper | af0dea1 | 2013-07-04 01:31:24 +0000 | [diff] [blame] | 237 | for (SmallVectorImpl<uint32_t>::iterator I = Lines.begin(), |
Bill Wendling | ea6397f | 2012-07-19 00:11:40 +0000 | [diff] [blame] | 238 | E = Lines.end(); I != E; ++I) |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 239 | FI.addLineCount(Filename, *I, Count); |
| 240 | } |
| 241 | |
Yuchen Wu | 0367815 | 2013-10-25 02:22:24 +0000 | [diff] [blame] | 242 | /// dump - Dump GCOVLines content to dbgs() for debugging purposes. |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 243 | void GCOVLines::dump() { |
Craig Topper | af0dea1 | 2013-07-04 01:31:24 +0000 | [diff] [blame] | 244 | for (SmallVectorImpl<uint32_t>::iterator I = Lines.begin(), |
Bill Wendling | ea6397f | 2012-07-19 00:11:40 +0000 | [diff] [blame] | 245 | E = Lines.end(); I != E; ++I) |
Yuchen Wu | 0367815 | 2013-10-25 02:22:24 +0000 | [diff] [blame] | 246 | dbgs() << (*I) << ","; |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | //===----------------------------------------------------------------------===// |
| 250 | // FileInfo implementation. |
| 251 | |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 252 | /// print - Print source files with collected line count information. |
Yuchen Wu | dbcf197 | 2013-11-02 00:09:17 +0000 | [diff] [blame^] | 253 | void FileInfo::print(raw_fd_ostream &OS, StringRef gcnoFile, |
| 254 | StringRef gcdaFile) { |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 255 | for (StringMap<LineCounts>::iterator I = LineInfo.begin(), E = LineInfo.end(); |
| 256 | I != E; ++I) { |
| 257 | StringRef Filename = I->first(); |
Yuchen Wu | dbcf197 | 2013-11-02 00:09:17 +0000 | [diff] [blame^] | 258 | OS << " -: 0:Source:" << Filename << "\n"; |
| 259 | OS << " -: 0:Graph:" << gcnoFile << "\n"; |
| 260 | OS << " -: 0:Data:" << gcdaFile << "\n"; |
| 261 | OS << " -: 0:Programs:" << ProgramCount << "\n"; |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 262 | LineCounts &L = LineInfo[Filename]; |
| 263 | OwningPtr<MemoryBuffer> Buff; |
| 264 | if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buff)) { |
| 265 | errs() << Filename << ": " << ec.message() << "\n"; |
| 266 | return; |
| 267 | } |
| 268 | StringRef AllLines = Buff.take()->getBuffer(); |
Yuchen Wu | 48342ee | 2013-10-23 19:45:03 +0000 | [diff] [blame] | 269 | uint32_t i = 0; |
| 270 | while (!AllLines.empty()) { |
| 271 | if (L.find(i) != L.end()) { |
| 272 | if (L[i] == 0) |
Yuchen Wu | dbcf197 | 2013-11-02 00:09:17 +0000 | [diff] [blame^] | 273 | OS << " #####:"; |
Yuchen Wu | 48342ee | 2013-10-23 19:45:03 +0000 | [diff] [blame] | 274 | else |
Yuchen Wu | dbcf197 | 2013-11-02 00:09:17 +0000 | [diff] [blame^] | 275 | OS << format("%9lu:", L[i]); |
Yuchen Wu | 48342ee | 2013-10-23 19:45:03 +0000 | [diff] [blame] | 276 | } else { |
Yuchen Wu | dbcf197 | 2013-11-02 00:09:17 +0000 | [diff] [blame^] | 277 | OS << " -:"; |
Yuchen Wu | 48342ee | 2013-10-23 19:45:03 +0000 | [diff] [blame] | 278 | } |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 279 | std::pair<StringRef, StringRef> P = AllLines.split('\n'); |
| 280 | if (AllLines != P.first) |
Yuchen Wu | dbcf197 | 2013-11-02 00:09:17 +0000 | [diff] [blame^] | 281 | OS << format("%5u:", i+1) << P.first; |
| 282 | OS << "\n"; |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 283 | AllLines = P.second; |
Yuchen Wu | 48342ee | 2013-10-23 19:45:03 +0000 | [diff] [blame] | 284 | ++i; |
Devang Patel | 3714065 | 2011-09-28 18:50:00 +0000 | [diff] [blame] | 285 | } |
| 286 | } |
| 287 | } |
| 288 | |