LCOV - code coverage report
Current view: top level - lib/Support - ScopedPrinter.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 24 25 96.0 %
Date: 2017-09-14 15:23:50 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13