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

          Line data    Source code
       1             : //===- TableGenBackend.cpp - Utilities for TableGen Backends ----*- 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             : // This file provides useful services for TableGen backends...
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #include "llvm/TableGen/TableGenBackend.h"
      15             : #include "llvm/ADT/Twine.h"
      16             : #include "llvm/Support/raw_ostream.h"
      17             : 
      18             : using namespace llvm;
      19             : 
      20             : const size_t MAX_LINE_LEN = 80U;
      21             : 
      22        1617 : static void printLine(raw_ostream &OS, const Twine &Prefix, char Fill,
      23             :                       StringRef Suffix) {
      24        1617 :   size_t Pos = (size_t)OS.tell();
      25             :   assert((Prefix.str().size() + Suffix.size() <= MAX_LINE_LEN) &&
      26             :          "header line exceeds max limit");
      27        1617 :   OS << Prefix;
      28       95733 :   for (size_t i = (size_t)OS.tell() - Pos, e = MAX_LINE_LEN - Suffix.size();
      29       94116 :          i < e; ++i)
      30      184998 :     OS << Fill;
      31        3234 :   OS << Suffix << '\n';
      32        1617 : }
      33             : 
      34         231 : void llvm::emitSourceFileHeader(StringRef Desc, raw_ostream &OS) {
      35         462 :   printLine(OS, "/*===- TableGen'erated file ", '-', "*- C++ -*-===*\\");
      36         231 :   StringRef Prefix("|* ");
      37         231 :   StringRef Suffix(" *|");
      38         231 :   printLine(OS, Prefix, ' ', Suffix);
      39         231 :   size_t PSLen = Prefix.size() + Suffix.size();
      40             :   assert(PSLen < MAX_LINE_LEN);
      41         231 :   size_t Pos = 0U;
      42             :   do {
      43         693 :     size_t Length = std::min(Desc.size() - Pos, MAX_LINE_LEN - PSLen);
      44         924 :     printLine(OS, Prefix + Desc.substr(Pos, Length), ' ', Suffix);
      45         231 :     Pos += Length;
      46         231 :   } while (Pos < Desc.size());
      47         231 :   printLine(OS, Prefix, ' ', Suffix);
      48         231 :   printLine(OS, Prefix + "Automatically generated file, do not edit!", ' ',
      49             :     Suffix);
      50         231 :   printLine(OS, Prefix, ' ', Suffix);
      51         462 :   printLine(OS, "\\*===", '-', "===*/");
      52         231 :   OS << '\n';
      53         231 : }

Generated by: LCOV version 1.13