Coverage Report

Created: 2019-02-20 00:17

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/CodeGen/DwarfStringPoolEntry.h
Line
Count
Source (jump to first uncovered line)
1
//===- llvm/CodeGen/DwarfStringPoolEntry.h - String pool entry --*- 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 LLVM_CODEGEN_DWARFSTRINGPOOLENTRY_H
10
#define LLVM_CODEGEN_DWARFSTRINGPOOLENTRY_H
11
12
#include "llvm/ADT/PointerIntPair.h"
13
#include "llvm/ADT/StringMap.h"
14
15
namespace llvm {
16
17
class MCSymbol;
18
19
/// Data for a string pool entry.
20
struct DwarfStringPoolEntry {
21
  static constexpr unsigned NotIndexed = -1;
22
23
  MCSymbol *Symbol;
24
  unsigned Offset;
25
  unsigned Index;
26
27
5.67k
  bool isIndexed() const { return Index != NotIndexed; }
28
};
29
30
/// String pool entry reference.
31
class DwarfStringPoolEntryRef {
32
  PointerIntPair<const StringMapEntry<DwarfStringPoolEntry> *, 1, bool>
33
      MapEntryAndIndexed;
34
35
785k
  const StringMapEntry<DwarfStringPoolEntry> *getMapEntry() const {
36
785k
    return MapEntryAndIndexed.getPointer();
37
785k
  }
38
39
public:
40
  DwarfStringPoolEntryRef() = default;
41
  DwarfStringPoolEntryRef(const StringMapEntry<DwarfStringPoolEntry> &Entry,
42
                          bool Indexed)
43
447k
      : MapEntryAndIndexed(&Entry, Indexed) {}
44
45
  explicit operator bool() const { return getMapEntry(); }
46
7.17k
  MCSymbol *getSymbol() const {
47
7.17k
    assert(getMapEntry()->second.Symbol && "No symbol available!");
48
7.17k
    return getMapEntry()->second.Symbol;
49
7.17k
  }
50
192k
  unsigned getOffset() const { return getMapEntry()->second.Offset; }
51
0
  bool isIndexed() const { return MapEntryAndIndexed.getInt(); }
52
17.8k
  unsigned getIndex() const {
53
17.8k
    assert(isIndexed());
54
17.8k
    assert(getMapEntry()->getValue().isIndexed());
55
17.8k
    return getMapEntry()->second.Index;
56
17.8k
  }
57
489k
  StringRef getString() const { return getMapEntry()->first(); }
58
  /// Return the entire string pool entry for convenience.
59
70.6k
  DwarfStringPoolEntry getEntry() const { return getMapEntry()->getValue(); }
60
61
0
  bool operator==(const DwarfStringPoolEntryRef &X) const {
62
0
    return getMapEntry() == X.getMapEntry();
63
0
  }
64
  bool operator!=(const DwarfStringPoolEntryRef &X) const {
65
    return getMapEntry() != X.getMapEntry();
66
  }
67
};
68
69
} // end namespace llvm
70
71
#endif