Coverage Report

Created: 2018-10-23 15:26

/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
using llvm::wasm::WasmGlobal;
20
using llvm::wasm::WasmInitExpr;
21
22
namespace lld {
23
namespace wasm {
24
25
// Represents a single Wasm Global Variable within an input file. These are
26
// combined to form the final GLOBALS section.
27
class InputGlobal {
28
public:
29
  InputGlobal(const WasmGlobal &G, ObjFile *F)
30
108
      : File(F), Global(G), Live(!Config->GcSections) {}
31
32
1
  StringRef getName() const { return Global.SymbolName; }
33
108
  const WasmGlobalType &getType() const { return Global.Type; }
34
35
15
  uint32_t getGlobalIndex() const { return GlobalIndex.getValue(); }
36
0
  bool hasGlobalIndex() const { return GlobalIndex.hasValue(); }
37
85
  void setGlobalIndex(uint32_t Index) {
38
85
    assert(!hasGlobalIndex());
39
85
    GlobalIndex = Index;
40
85
  }
41
42
  ObjFile *File;
43
  WasmGlobal Global;
44
45
  bool Live = false;
46
47
protected:
48
  llvm::Optional<uint32_t> GlobalIndex;
49
};
50
51
} // namespace wasm
52
53
1
inline std::string toString(const wasm::InputGlobal *G) {
54
1
  return (toString(G->File) + ":(" + G->getName() + ")").str();
55
1
}
56
57
} // namespace lld
58
59
#endif // LLD_WASM_INPUT_GLOBAL_H