Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/wasm/InputEvent.h
Line
Count
Source (jump to first uncovered line)
1
//===- InputEvent.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
// Wasm events are features that suspend the current execution and transfer the
10
// control flow to a corresponding handler. Currently the only supported event
11
// kind is exceptions.
12
//
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLD_WASM_INPUT_EVENT_H
16
#define LLD_WASM_INPUT_EVENT_H
17
18
#include "Config.h"
19
#include "InputFiles.h"
20
#include "WriterUtils.h"
21
#include "lld/Common/ErrorHandler.h"
22
#include "llvm/Object/Wasm.h"
23
24
namespace lld {
25
namespace wasm {
26
27
// Represents a single Wasm Event within an input file. These are combined to
28
// form the final EVENTS section.
29
class InputEvent {
30
public:
31
  InputEvent(const WasmSignature &s, const WasmEvent &e, ObjFile *f)
32
2
      : file(f), event(e), signature(s), live(!config->gcSections) {}
33
34
0
  StringRef getName() const { return event.SymbolName; }
35
2
  const WasmEventType &getType() const { return event.Type; }
36
37
2
  uint32_t getEventIndex() const { return eventIndex.getValue(); }
38
0
  bool hasEventIndex() const { return eventIndex.hasValue(); }
39
1
  void setEventIndex(uint32_t index) {
40
1
    assert(!hasEventIndex());
41
1
    eventIndex = index;
42
1
  }
43
44
  ObjFile *file;
45
  WasmEvent event;
46
  const WasmSignature &signature;
47
48
  bool live = false;
49
50
protected:
51
  llvm::Optional<uint32_t> eventIndex;
52
};
53
54
} // namespace wasm
55
56
0
inline std::string toString(const wasm::InputEvent *e) {
57
0
  return (toString(e->file) + ":(" + e->getName() + ")").str();
58
0
}
59
60
} // namespace lld
61
62
#endif // LLD_WASM_INPUT_EVENT_H