Coverage Report

Created: 2018-11-12 17:33

/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
//                     The LLVM Compiler Infrastructure
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 LLVM_CODEGEN_DWARFSTRINGPOOLENTRY_H
11
#define LLVM_CODEGEN_DWARFSTRINGPOOLENTRY_H
12
13
#include "llvm/ADT/PointerIntPair.h"
14
#include "llvm/ADT/StringMap.h"
15
16
namespace llvm {
17
18
class MCSymbol;
19
20
/// Data for a string pool entry.
21
struct DwarfStringPoolEntry {
22
  static constexpr unsigned NotIndexed = -1;
23
24
  MCSymbol *Symbol;
25
  unsigned Offset;
26
  unsigned Index;
27
28
5.30k
  bool isIndexed() const { return Index != NotIndexed; }
29
};
30
31
/// String pool entry reference.
32
class DwarfStringPoolEntryRef {
33
  PointerIntPair<const StringMapEntry<DwarfStringPoolEntry> *, 1, bool>
34
      MapEntryAndIndexed;
35
36
793k
  const StringMapEntry<DwarfStringPoolEntry> *getMapEntry() const {
37
793k
    return MapEntryAndIndexed.getPointer();
38
793k
  }
39
40
public:
41
  DwarfStringPoolEntryRef() = default;
42
  DwarfStringPoolEntryRef(const StringMapEntry<DwarfStringPoolEntry> &Entry,
43
                          bool Indexed)
44
446k
      : MapEntryAndIndexed(&Entry, Indexed) {}
45
46
  explicit operator bool() const { return getMapEntry(); }
47
6.21k
  MCSymbol *getSymbol() const {
48
6.21k
    assert(getMapEntry()->second.Symbol && "No symbol available!");
49
6.21k
    return getMapEntry()->second.Symbol;
50
6.21k
  }
51
198k
  unsigned getOffset() const { return getMapEntry()->second.Offset; }
52
0
  bool isIndexed() const { return MapEntryAndIndexed.getInt(); }
53
16.7k
  unsigned getIndex() const {
54
16.7k
    assert(isIndexed());
55
16.7k
    assert(getMapEntry()->getValue().isIndexed());
56
16.7k
    return getMapEntry()->second.Index;
57
16.7k
  }
58
490k
  StringRef getString() const { return getMapEntry()->first(); }
59
  /// Return the entire string pool entry for convenience.
60
73.5k
  DwarfStringPoolEntry getEntry() const { return getMapEntry()->getValue(); }
61
62
0
  bool operator==(const DwarfStringPoolEntryRef &X) const {
63
0
    return getMapEntry() == X.getMapEntry();
64
0
  }
65
  bool operator!=(const DwarfStringPoolEntryRef &X) const {
66
    return getMapEntry() != X.getMapEntry();
67
  }
68
};
69
70
} // end namespace llvm
71
72
#endif