Coverage Report

Created: 2019-07-24 05:18

/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
// 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
#ifndef LLD_WASM_INPUT_GLOBAL_H
10
#define LLD_WASM_INPUT_GLOBAL_H
11
12
#include "Config.h"
13
#include "InputFiles.h"
14
#include "WriterUtils.h"
15
#include "lld/Common/ErrorHandler.h"
16
#include "llvm/Object/Wasm.h"
17
18
namespace lld {
19
namespace wasm {
20
21
// Represents a single Wasm Global Variable within an input file. These are
22
// combined to form the final GLOBALS section.
23
class InputGlobal {
24
public:
25
  InputGlobal(const WasmGlobal &g, ObjFile *f)
26
246
      : file(f), global(g), live(!config->gcSections) {}
27
28
1
  StringRef getName() const { return global.SymbolName; }
29
246
  const WasmGlobalType &getType() const { return global.Type; }
30
31
26
  uint32_t getGlobalIndex() const { return globalIndex.getValue(); }
32
0
  bool hasGlobalIndex() const { return globalIndex.hasValue(); }
33
200
  void setGlobalIndex(uint32_t index) {
34
200
    assert(!hasGlobalIndex());
35
200
    globalIndex = index;
36
200
  }
37
38
  ObjFile *file;
39
  WasmGlobal global;
40
41
  bool live = false;
42
43
protected:
44
  llvm::Optional<uint32_t> globalIndex;
45
};
46
47
} // namespace wasm
48
49
1
inline std::string toString(const wasm::InputGlobal *g) {
50
1
  return (toString(g->file) + ":(" + g->getName() + ")").str();
51
1
}
52
53
} // namespace lld
54
55
#endif // LLD_WASM_INPUT_GLOBAL_H