Coverage Report

Created: 2019-01-18 03:29

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/wasm/InputGlobal.h
Line
Count
Source (jump to first uncovered line)
1
//===- InputGlobal.h --------------------------------------------*- C++ -*-===//
2
//
3
//                             The LLVM Linker
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#ifndef LLD_WASM_INPUT_GLOBAL_H
11
#define LLD_WASM_INPUT_GLOBAL_H
12
13
#include "Config.h"
14
#include "InputFiles.h"
15
#include "WriterUtils.h"
16
#include "lld/Common/ErrorHandler.h"
17
#include "llvm/Object/Wasm.h"
18
19
namespace lld {
20
namespace wasm {
21
22
// Represents a single Wasm Global Variable within an input file. These are
23
// combined to form the final GLOBALS section.
24
class InputGlobal {
25
public:
26
  InputGlobal(const WasmGlobal &G, ObjFile *F)
27
114
      : File(F), Global(G), Live(!Config->GcSections) {}
28
29
1
  StringRef getName() const { return Global.SymbolName; }
30
114
  const WasmGlobalType &getType() const { return Global.Type; }
31
32
15
  uint32_t getGlobalIndex() const { return GlobalIndex.getValue(); }
33
0
  bool hasGlobalIndex() const { return GlobalIndex.hasValue(); }
34
91
  void setGlobalIndex(uint32_t Index) {
35
91
    assert(!hasGlobalIndex());
36
91
    GlobalIndex = Index;
37
91
  }
38
39
  ObjFile *File;
40
  WasmGlobal Global;
41
42
  bool Live = false;
43
44
protected:
45
  llvm::Optional<uint32_t> GlobalIndex;
46
};
47
48
} // namespace wasm
49
50
1
inline std::string toString(const wasm::InputGlobal *G) {
51
1
  return (toString(G->File) + ":(" + G->getName() + ")").str();
52
1
}
53
54
} // namespace lld
55
56
#endif // LLD_WASM_INPUT_GLOBAL_H