Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/MC/MCSymbolWasm.h
Line
Count
Source (jump to first uncovered line)
1
//===- MCSymbolWasm.h -  ----------------------------------------*- C++ -*-===//
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
#ifndef LLVM_MC_MCSYMBOLWASM_H
9
#define LLVM_MC_MCSYMBOLWASM_H
10
11
#include "llvm/BinaryFormat/Wasm.h"
12
#include "llvm/MC/MCSymbol.h"
13
14
namespace llvm {
15
16
class MCSymbolWasm : public MCSymbol {
17
  wasm::WasmSymbolType Type = wasm::WASM_SYMBOL_TYPE_DATA;
18
  bool IsWeak = false;
19
  bool IsHidden = false;
20
  bool IsComdat = false;
21
  mutable bool IsUsedInGOT = false;
22
  Optional<std::string> ImportModule;
23
  Optional<std::string> ImportName;
24
  wasm::WasmSignature *Signature = nullptr;
25
  Optional<wasm::WasmGlobalType> GlobalType;
26
  Optional<wasm::WasmEventType> EventType;
27
28
  /// An expression describing how to calculate the size of a symbol. If a
29
  /// symbol has no size this field will be NULL.
30
  const MCExpr *SymbolSize = nullptr;
31
32
public:
33
  // Use a module name of "env" for now, for compatibility with existing tools.
34
  // This is temporary, and may change, as the ABI is not yet stable.
35
  MCSymbolWasm(const StringMapEntry<bool> *Name, bool isTemporary)
36
25.0k
      : MCSymbol(SymbolKindWasm, Name, isTemporary) {}
37
0
  static bool classof(const MCSymbol *S) { return S->isWasm(); }
38
39
1.21k
  const MCExpr *getSize() const { return SymbolSize; }
40
584
  void setSize(const MCExpr *SS) { SymbolSize = SS; }
41
42
6.48k
  bool isFunction() const { return Type == wasm::WASM_SYMBOL_TYPE_FUNCTION; }
43
1.88k
  bool isData() const { return Type == wasm::WASM_SYMBOL_TYPE_DATA; }
44
1.36k
  bool isGlobal() const { return Type == wasm::WASM_SYMBOL_TYPE_GLOBAL; }
45
1.36k
  bool isSection() const { return Type == wasm::WASM_SYMBOL_TYPE_SECTION; }
46
3.29k
  bool isEvent() const { return Type == wasm::WASM_SYMBOL_TYPE_EVENT; }
47
12.2k
  wasm::WasmSymbolType getType() const { return Type; }
48
20.1k
  void setType(wasm::WasmSymbolType type) { Type = type; }
49
50
731
  bool isExported() const {
51
731
    return getFlags() & wasm::WASM_SYMBOL_EXPORTED;
52
731
  }
53
4
  void setExported() const {
54
4
    modifyFlags(wasm::WASM_SYMBOL_EXPORTED, wasm::WASM_SYMBOL_EXPORTED);
55
4
  }
56
57
749
  bool isWeak() const { return IsWeak; }
58
84
  void setWeak(bool isWeak) { IsWeak = isWeak; }
59
60
731
  bool isHidden() const { return IsHidden; }
61
137
  void setHidden(bool isHidden) { IsHidden = isHidden; }
62
63
3.72k
  bool isComdat() const { return IsComdat; }
64
13
  void setComdat(bool isComdat) { IsComdat = isComdat; }
65
66
108
  const StringRef getImportModule() const {
67
108
      if (ImportModule.hasValue()) {
68
4
          return ImportModule.getValue();
69
4
      }
70
104
      return "env";
71
104
  }
72
5
  void setImportModule(StringRef Name) { ImportModule = Name; }
73
74
839
  const StringRef getImportName() const {
75
839
      if (ImportName.hasValue()) {
76
6
          return ImportName.getValue();
77
6
      }
78
833
      return getName();
79
833
  }
80
4
  void setImportName(StringRef Name) { ImportName = Name; }
81
82
8
  void setUsedInGOT() const { IsUsedInGOT = true; }
83
2.15k
  bool isUsedInGOT() const { return IsUsedInGOT; }
84
85
5.31k
  const wasm::WasmSignature *getSignature() const { return Signature; }
86
5.60k
  void setSignature(wasm::WasmSignature *Sig) { Signature = Sig; }
87
88
92
  const wasm::WasmGlobalType &getGlobalType() const {
89
92
    assert(GlobalType.hasValue());
90
92
    return GlobalType.getValue();
91
92
  }
92
497
  void setGlobalType(wasm::WasmGlobalType GT) { GlobalType = GT; }
93
94
0
  const wasm::WasmEventType &getEventType() const {
95
0
    assert(EventType.hasValue());
96
0
    return EventType.getValue();
97
0
  }
98
51
  void setEventType(wasm::WasmEventType ET) { EventType = ET; }
99
};
100
101
} // end namespace llvm
102
103
#endif // LLVM_MC_MCSYMBOLWASM_H