LCOV - code coverage report
Current view: top level - lib/DebugInfo/DWARF - SyntaxHighlighting.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 9 17 52.9 %
Date: 2017-09-14 15:23:50 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- SyntaxHighlighting.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 "SyntaxHighlighting.h"
      11             : #include "llvm/Support/CommandLine.h"
      12             : #include "llvm/Support/raw_ostream.h"
      13             : 
      14             : using namespace llvm;
      15             : using namespace dwarf;
      16             : using namespace syntax;
      17             : 
      18             : static cl::opt<cl::boolOrDefault>
      19       72306 :     UseColor("color",
      20      216918 :              cl::desc("use colored syntax highlighting (default=autodetect)"),
      21      289224 :              cl::init(cl::BOU_UNSET));
      22             : 
      23       44469 : WithColor::WithColor(raw_ostream &OS, enum HighlightColor Type) : OS(OS) {
      24             :   // Detect color from terminal type unless the user passed the --color option.
      25       44469 :   if (UseColor == cl::BOU_UNSET ? OS.has_colors() : UseColor == cl::BOU_TRUE) {
      26           0 :     switch (Type) {
      27           0 :     case Address:    OS.changeColor(raw_ostream::YELLOW);  break;
      28           0 :     case String:     OS.changeColor(raw_ostream::GREEN);   break;
      29           0 :     case Tag:        OS.changeColor(raw_ostream::BLUE);    break;
      30           0 :     case Attribute:  OS.changeColor(raw_ostream::CYAN);    break;
      31           0 :     case Enumerator: OS.changeColor(raw_ostream::MAGENTA); break;
      32           0 :     case Macro:      OS.changeColor(raw_ostream::RED);     break;
      33             :     }
      34             :   }
      35       44469 : }
      36             : 
      37       88938 : WithColor::~WithColor() {
      38       44469 :   if (UseColor == cl::BOU_UNSET ? OS.has_colors() : UseColor == cl::BOU_TRUE)
      39           0 :     OS.resetColor();
      40      261387 : }

Generated by: LCOV version 1.13