Coverage Report

Created: 2019-02-20 07:29

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/MC/MCSymbolWasm.h
Line
Count
Source
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
  Optional<std::string> ImportModule;
22
  Optional<std::string> ImportName;
23
  wasm::WasmSignature *Signature = nullptr;
24
  Optional<wasm::WasmGlobalType> GlobalType;
25
  Optional<wasm::WasmEventType> EventType;
26
27
  /// An expression describing how to calculate the size of a symbol. If a
28
  /// symbol has no size this field will be NULL.
29
  const MCExpr *SymbolSize = nullptr;
30
31
public:
32
  // Use a module name of "env" for now, for compatibility with existing tools.
33
  // This is temporary, and may change, as the ABI is not yet stable.
34
  MCSymbolWasm(const StringMapEntry<bool> *Name, bool isTemporary)
35
20.6k
      : MCSymbol(SymbolKindWasm, Name, isTemporary) {}
36
  static bool classof(const MCSymbol *S) { return S->isWasm(); }
37
38
1.00k
  const MCExpr *getSize() const { return SymbolSize; }
39
482
  void setSize(const MCExpr *SS) { SymbolSize = SS; }
40
41
5.44k
  bool isFunction() const { return Type == wasm::WASM_SYMBOL_TYPE_FUNCTION; }
42
1.50k
  bool isData() const { return Type == wasm::WASM_SYMBOL_TYPE_DATA; }
43
746
  bool isGlobal() const { return Type == wasm::WASM_SYMBOL_TYPE_GLOBAL; }
44
1.06k
  bool isSection() const { return Type == wasm::WASM_SYMBOL_TYPE_SECTION; }
45
2.56k
  bool isEvent() const { return Type == wasm::WASM_SYMBOL_TYPE_EVENT; }
46
10.0k
  wasm::WasmSymbolType getType() const { return Type; }
47
16.3k
  void setType(wasm::WasmSymbolType type) { Type = type; }
48
49
612
  bool isExported() const {
50
612
    return getFlags() & wasm::WASM_SYMBOL_EXPORTED;
51
612
  }
52
2
  void setExported() const {
53
2
    modifyFlags(wasm::WASM_SYMBOL_EXPORTED, wasm::WASM_SYMBOL_EXPORTED);
54
2
  }
55
56
624
  bool isWeak() const { return IsWeak; }
57
65
  void setWeak(bool isWeak) { IsWeak = isWeak; }
58
59
613
  bool isHidden() const { return IsHidden; }
60
108
  void setHidden(bool isHidden) { IsHidden = isHidden; }
61
62
3.03k
  bool isComdat() const { return IsComdat; }
63
9
  void setComdat(bool isComdat) { IsComdat = isComdat; }
64
65
448
  const StringRef getImportModule() const {
66
448
      if (ImportModule.hasValue()) {
67
4
          return ImportModule.getValue();
68
4
      }
69
444
      return "env";
70
444
  }
71
5
  void setImportModule(StringRef Name) { ImportModule = Name; }
72
73
1.06k
  const StringRef getImportName() const {
74
1.06k
      if (ImportName.hasValue()) {
75
6
          return ImportName.getValue();
76
6
      }
77
1.05k
      return getName();
78
1.05k
  }
79
4
  void setImportName(StringRef Name) { ImportName = Name; }
80
81
4.33k
  const wasm::WasmSignature *getSignature() const { return Signature; }
82
4.42k
  void setSignature(wasm::WasmSignature *Sig) { Signature = Sig; }
83
84
54
  const wasm::WasmGlobalType &getGlobalType() const {
85
54
    assert(GlobalType.hasValue());
86
54
    return GlobalType.getValue();
87
54
  }
88
346
  void setGlobalType(wasm::WasmGlobalType GT) { GlobalType = GT; }
89
90
  const wasm::WasmEventType &getEventType() const {
91
    assert(EventType.hasValue());
92
    return EventType.getValue();
93
  }
94
29
  void setEventType(wasm::WasmEventType ET) { EventType = ET; }
95
};
96
97
} // end namespace llvm
98
99
#endif // LLVM_MC_MCSYMBOLWASM_H