Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/MC/MCSectionWasm.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- lib/MC/MCSectionWasm.cpp - Wasm Code Section Representation --------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include "llvm/MC/MCSectionWasm.h"
10
#include "llvm/MC/MCAsmInfo.h"
11
#include "llvm/MC/MCExpr.h"
12
#include "llvm/MC/MCSymbol.h"
13
#include "llvm/Support/raw_ostream.h"
14
15
using namespace llvm;
16
17
// Decides whether a '.section' directive
18
// should be printed before the section name.
19
bool MCSectionWasm::shouldOmitSectionDirective(StringRef Name,
20
4.66k
                                               const MCAsmInfo &MAI) const {
21
4.66k
  return MAI.shouldOmitSectionDirective(Name);
22
4.66k
}
23
24
4.43k
static void printName(raw_ostream &OS, StringRef Name) {
25
4.43k
  if (Name.find_first_not_of("0123456789_."
26
4.43k
                             "abcdefghijklmnopqrstuvwxyz"
27
4.43k
                             "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == Name.npos) {
28
4.42k
    OS << Name;
29
4.42k
    return;
30
4.42k
  }
31
1
  OS << '"';
32
79
  for (const char *B = Name.begin(), *E = Name.end(); B < E; 
++B78
) {
33
78
    if (*B == '"') // Unquoted "
34
0
      OS << "\\\"";
35
78
    else if (*B != '\\') // Neither " or backslash
36
78
      OS << *B;
37
0
    else if (B + 1 == E) // Trailing backslash
38
0
      OS << "\\\\";
39
0
    else {
40
0
      OS << B[0] << B[1]; // Quoted character
41
0
      ++B;
42
0
    }
43
78
  }
44
1
  OS << '"';
45
1
}
46
47
void MCSectionWasm::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
48
                                         raw_ostream &OS,
49
4.66k
                                         const MCExpr *Subsection) const {
50
4.66k
51
4.66k
  if (shouldOmitSectionDirective(SectionName, MAI)) {
52
239
    OS << '\t' << getSectionName();
53
239
    if (Subsection) {
54
0
      OS << '\t';
55
0
      Subsection->print(OS, &MAI);
56
0
    }
57
239
    OS << '\n';
58
239
    return;
59
239
  }
60
4.43k
61
4.43k
  OS << "\t.section\t";
62
4.43k
  printName(OS, getSectionName());
63
4.43k
  OS << ",\"";
64
4.43k
65
4.43k
  if (IsPassive)
66
0
    OS << "passive";
67
4.43k
68
4.43k
  OS << '"';
69
4.43k
70
4.43k
  OS << ',';
71
4.43k
72
4.43k
  // If comment string is '@', e.g. as on ARM - use '%' instead
73
4.43k
  if (MAI.getCommentString()[0] == '@')
74
0
    OS << '%';
75
4.43k
  else
76
4.43k
    OS << '@';
77
4.43k
78
4.43k
  // TODO: Print section type.
79
4.43k
80
4.43k
  if (isUnique())
81
0
    OS << ",unique," << UniqueID;
82
4.43k
83
4.43k
  OS << '\n';
84
4.43k
85
4.43k
  if (Subsection) {
86
0
    OS << "\t.subsection\t";
87
0
    Subsection->print(OS, &MAI);
88
0
    OS << '\n';
89
0
  }
90
4.43k
}
91
92
230
bool MCSectionWasm::UseCodeAlign() const { return false; }
93
94
2.18k
bool MCSectionWasm::isVirtualSection() const { return false; }