Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/MC/MCSectionWasm.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- lib/MC/MCSectionWasm.cpp - Wasm Code Section Representation --------===//
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/MC/MCSectionWasm.h"
11
#include "llvm/MC/MCAsmInfo.h"
12
#include "llvm/MC/MCContext.h"
13
#include "llvm/MC/MCExpr.h"
14
#include "llvm/MC/MCSymbol.h"
15
#include "llvm/Support/raw_ostream.h"
16
17
using namespace llvm;
18
19
0
MCSectionWasm::~MCSectionWasm() {} // anchor.
20
21
// Decides whether a '.section' directive
22
// should be printed before the section name.
23
bool MCSectionWasm::ShouldOmitSectionDirective(StringRef Name,
24
0
                                               const MCAsmInfo &MAI) const {
25
0
  return MAI.shouldOmitSectionDirective(Name);
26
0
}
27
28
0
static void printName(raw_ostream &OS, StringRef Name) {
29
0
  if (Name.find_first_not_of("0123456789_."
30
0
                             "abcdefghijklmnopqrstuvwxyz"
31
0
                             "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == Name.npos) {
32
0
    OS << Name;
33
0
    return;
34
0
  }
35
0
  OS << '"';
36
0
  for (const char *B = Name.begin(), *E = Name.end(); 
B < E0
;
++B0
) {
37
0
    if (*B == '"') // Unquoted "
38
0
      OS << "\\\"";
39
0
    else 
if (0
*B != '\\'0
) // Neither " or backslash
40
0
      OS << *B;
41
0
    else 
if (0
B + 1 == E0
) // Trailing backslash
42
0
      OS << "\\\\";
43
0
    else {
44
0
      OS << B[0] << B[1]; // Quoted character
45
0
      ++B;
46
0
    }
47
0
  }
48
0
  OS << '"';
49
0
}
50
51
void MCSectionWasm::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
52
                                         raw_ostream &OS,
53
0
                                         const MCExpr *Subsection) const {
54
0
55
0
  if (
ShouldOmitSectionDirective(SectionName, MAI)0
) {
56
0
    OS << '\t' << getSectionName();
57
0
    if (
Subsection0
) {
58
0
      OS << '\t';
59
0
      Subsection->print(OS, &MAI);
60
0
    }
61
0
    OS << '\n';
62
0
    return;
63
0
  }
64
0
65
0
  OS << "\t.section\t";
66
0
  printName(OS, getSectionName());
67
0
  OS << ",\"";
68
0
69
0
  // TODO: Print section flags.
70
0
71
0
  OS << '"';
72
0
73
0
  OS << ',';
74
0
75
0
  // If comment string is '@', e.g. as on ARM - use '%' instead
76
0
  if (MAI.getCommentString()[0] == '@')
77
0
    OS << '%';
78
0
  else
79
0
    OS << '@';
80
0
81
0
  // TODO: Print section type.
82
0
83
0
  if (isUnique())
84
0
    OS << ",unique," << UniqueID;
85
0
86
0
  OS << '\n';
87
0
88
0
  if (
Subsection0
) {
89
0
    OS << "\t.subsection\t";
90
0
    Subsection->print(OS, &MAI);
91
0
    OS << '\n';
92
0
  }
93
0
}
94
95
0
bool MCSectionWasm::UseCodeAlign() const { return false; }
96
97
0
bool MCSectionWasm::isVirtualSection() const { return false; }