LCOV - code coverage report
Current view: top level - lib/Support - ScopedPrinter.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 23 24 95.8 %
Date: 2018-10-20 13:21:21 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #include "llvm/Support/ScopedPrinter.h"
       2             : 
       3             : #include "llvm/Support/Format.h"
       4             : #include <cctype>
       5             : 
       6             : using namespace llvm::support;
       7             : 
       8             : namespace llvm {
       9             : 
      10     2216977 : raw_ostream &operator<<(raw_ostream &OS, const HexNumber &Value) {
      11     2216977 :   OS << "0x" << to_hexString(Value.Value);
      12     2216977 :   return OS;
      13             : }
      14             : 
      15     2217525 : const std::string to_hexString(uint64_t Value, bool UpperCase) {
      16             :   std::string number;
      17     2217525 :   llvm::raw_string_ostream stream(number);
      18     2217525 :   stream << format_hex_no_prefix(Value, 1, UpperCase);
      19     2217525 :   return stream.str();
      20             : }
      21             : 
      22        4989 : void ScopedPrinter::printBinaryImpl(StringRef Label, StringRef Str,
      23             :                                     ArrayRef<uint8_t> Data, bool Block,
      24             :                                     uint32_t StartOffset) {
      25        4989 :   if (Data.size() > 16)
      26             :     Block = true;
      27             : 
      28        3697 :   if (Block) {
      29        2589 :     startLine() << Label;
      30        2589 :     if (!Str.empty())
      31           0 :       OS << ": " << Str;
      32        2589 :     OS << " (\n";
      33        2589 :     if (!Data.empty())
      34        2041 :       OS << format_bytes_with_ascii(Data, StartOffset, 16, 4,
      35        4082 :                                     (IndentLevel + 1) * 2, true)
      36        2041 :          << "\n";
      37        2589 :     startLine() << ")\n";
      38             :   } else {
      39        2400 :     startLine() << Label << ":";
      40        2400 :     if (!Str.empty())
      41        1454 :       OS << " " << Str;
      42        2456 :     OS << " (" << format_bytes(Data, None, Data.size(), 1, 0, true) << ")\n";
      43             :   }
      44        4989 : }
      45             : 
      46             : } // namespace llvm

Generated by: LCOV version 1.13