LCOV - code coverage report
Current view: top level - lib/DebugInfo/CodeView - Formatters.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 18 20 90.0 %
Date: 2017-09-14 15:23:50 Functions: 3 4 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- Formatters.cpp -----------------------------------------------------===//
       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 "llvm/DebugInfo/CodeView/Formatters.h"
      11             : #include "llvm/ADT/ArrayRef.h"
      12             : #include "llvm/DebugInfo/CodeView/GUID.h"
      13             : #include "llvm/Support/raw_ostream.h"
      14             : #include <algorithm>
      15             : #include <cassert>
      16             : 
      17             : using namespace llvm;
      18             : using namespace llvm::codeview;
      19             : using namespace llvm::codeview::detail;
      20             : 
      21           0 : GuidAdapter::GuidAdapter(StringRef Guid)
      22           0 :     : FormatAdapter(makeArrayRef(Guid.bytes_begin(), Guid.bytes_end())) {}
      23             : 
      24          20 : GuidAdapter::GuidAdapter(ArrayRef<uint8_t> Guid)
      25          60 :     : FormatAdapter(std::move(Guid)) {}
      26             : 
      27          20 : void GuidAdapter::format(raw_ostream &Stream, StringRef Style) {
      28             :   static const char *Lookup = "0123456789ABCDEF";
      29             : 
      30             :   assert(Item.size() == 16 && "Expected 16-byte GUID");
      31          20 :   Stream << "{";
      32          20 :   for (int i = 0; i < 16;) {
      33         640 :     uint8_t Byte = Item[i];
      34         320 :     uint8_t HighNibble = (Byte >> 4) & 0xF;
      35         320 :     uint8_t LowNibble = Byte & 0xF;
      36         960 :     Stream << Lookup[HighNibble] << Lookup[LowNibble];
      37         320 :     ++i;
      38         320 :     if (i >= 4 && i <= 10 && i % 2 == 0)
      39          80 :       Stream << "-";
      40             :   }
      41          20 :   Stream << "}";
      42          20 : }
      43             : 
      44          16 : raw_ostream &llvm::codeview::operator<<(raw_ostream &OS, const GUID &Guid) {
      45          48 :   codeview::detail::GuidAdapter A(Guid.Guid);
      46          16 :   A.format(OS, "");
      47          32 :   return OS;
      48             : }

Generated by: LCOV version 1.13