Coverage Report

Created: 2019-05-19 14:56

/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
167
      : File(F), Global(G), Live(!Config->GcSections) {}
27
28
1
  StringRef getName() const { return Global.SymbolName; }
29
167
  const WasmGlobalType &getType() const { return Global.Type; }
30
31
18
  uint32_t getGlobalIndex() const { return GlobalIndex.getValue(); }
32
0
  bool hasGlobalIndex() const { return GlobalIndex.hasValue(); }
33
141
  void setGlobalIndex(uint32_t Index) {
34
141
    assert(!hasGlobalIndex());
35
141
    GlobalIndex = Index;
36
141
  }
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