Zachary Turner | 6305545 | 2017-06-15 22:24:24 +0000 | [diff] [blame] | 1 | //===- FormatUtil.cpp ----------------------------------------- *- C++ --*-===// |
| 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 | |
| 10 | #include "FormatUtil.h" |
| 11 | #include "llvm/ADT/STLExtras.h" |
| 12 | #include "llvm/ADT/StringExtras.h" |
| 13 | #include "llvm/Support/FormatAdapters.h" |
| 14 | #include "llvm/Support/FormatVariadic.h" |
| 15 | |
| 16 | using namespace llvm; |
| 17 | using namespace llvm::pdb; |
| 18 | |
| 19 | std::string llvm::pdb::typesetItemList(ArrayRef<std::string> Opts, |
Zachary Turner | 47d9a56 | 2017-06-16 00:04:24 +0000 | [diff] [blame] | 20 | uint32_t IndentLevel, uint32_t GroupSize, |
Zachary Turner | 6305545 | 2017-06-15 22:24:24 +0000 | [diff] [blame] | 21 | StringRef Sep) { |
| 22 | std::string Result; |
| 23 | while (!Opts.empty()) { |
| 24 | ArrayRef<std::string> ThisGroup; |
| 25 | ThisGroup = Opts.take_front(GroupSize); |
| 26 | Opts = Opts.drop_front(ThisGroup.size()); |
| 27 | Result += join(ThisGroup, Sep); |
| 28 | if (!Opts.empty()) { |
| 29 | Result += Sep; |
| 30 | Result += "\n"; |
| 31 | Result += formatv("{0}", fmt_repeat(' ', IndentLevel)); |
| 32 | } |
| 33 | } |
| 34 | return Result; |
| 35 | } |
| 36 | |
| 37 | std::string llvm::pdb::typesetStringList(uint32_t IndentLevel, |
| 38 | ArrayRef<StringRef> Strings) { |
| 39 | std::string Result = "["; |
| 40 | for (const auto &S : Strings) { |
| 41 | Result += formatv("\n{0}{1}", fmt_repeat(' ', IndentLevel), S); |
| 42 | } |
| 43 | Result += "]"; |
| 44 | return Result; |
| 45 | } |
| 46 | |
| 47 | std::string llvm::pdb::formatSegmentOffset(uint16_t Segment, uint32_t Offset) { |
| 48 | return formatv("{0:4}:{1:4}", Segment, Offset); |
| 49 | } |