Coverage Report

Created: 2018-09-23 16:00

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/AST/BaseSubobject.h
Line
Count
Source
1
//===- BaseSubobject.h - BaseSubobject class --------------------*- 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
// This file provides a definition of the BaseSubobject class.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CLANG_AST_BASESUBOBJECT_H
15
#define LLVM_CLANG_AST_BASESUBOBJECT_H
16
17
#include "clang/AST/CharUnits.h"
18
#include "llvm/ADT/DenseMapInfo.h"
19
#include "llvm/Support/type_traits.h"
20
#include <cstdint>
21
#include <utility>
22
23
namespace clang {
24
25
class CXXRecordDecl;
26
27
// BaseSubobject - Uniquely identifies a direct or indirect base class.
28
// Stores both the base class decl and the offset from the most derived class to
29
// the base class. Used for vtable and VTT generation.
30
class BaseSubobject {
31
  /// Base - The base class declaration.
32
  const CXXRecordDecl *Base;
33
34
  /// BaseOffset - The offset from the most derived class to the base class.
35
  CharUnits BaseOffset;
36
37
public:
38
5.88k
  BaseSubobject() = default;
39
  BaseSubobject(const CXXRecordDecl *Base, CharUnits BaseOffset)
40
281k
      : Base(Base), BaseOffset(BaseOffset) {}
41
42
  /// getBase - Returns the base class declaration.
43
239k
  const CXXRecordDecl *getBase() const { return Base; }
44
45
  /// getBaseOffset - Returns the base class offset.
46
310k
  CharUnits getBaseOffset() const { return BaseOffset; }
47
48
989k
  friend bool operator==(const BaseSubobject &LHS, const BaseSubobject &RHS) {
49
989k
    return LHS.Base == RHS.Base && 
LHS.BaseOffset == RHS.BaseOffset907k
;
50
989k
 }
51
};
52
53
} // namespace clang
54
55
namespace llvm {
56
57
template<> struct DenseMapInfo<clang::BaseSubobject> {
58
83.2k
  static clang::BaseSubobject getEmptyKey() {
59
83.2k
    return clang::BaseSubobject(
60
83.2k
      DenseMapInfo<const clang::CXXRecordDecl *>::getEmptyKey(),
61
83.2k
      clang::CharUnits::fromQuantity(DenseMapInfo<int64_t>::getEmptyKey()));
62
83.2k
  }
63
64
51.3k
  static clang::BaseSubobject getTombstoneKey() {
65
51.3k
    return clang::BaseSubobject(
66
51.3k
      DenseMapInfo<const clang::CXXRecordDecl *>::getTombstoneKey(),
67
51.3k
      clang::CharUnits::fromQuantity(DenseMapInfo<int64_t>::getTombstoneKey()));
68
51.3k
  }
69
70
33.5k
  static unsigned getHashValue(const clang::BaseSubobject &Base) {
71
33.5k
    using PairTy = std::pair<const clang::CXXRecordDecl *, clang::CharUnits>;
72
33.5k
73
33.5k
    return DenseMapInfo<PairTy>::getHashValue(PairTy(Base.getBase(),
74
33.5k
                                                     Base.getBaseOffset()));
75
33.5k
  }
76
77
  static bool isEqual(const clang::BaseSubobject &LHS,
78
987k
                      const clang::BaseSubobject &RHS) {
79
987k
    return LHS == RHS;
80
987k
  }
81
};
82
83
// It's OK to treat BaseSubobject as a POD type.
84
template <> struct isPodLike<clang::BaseSubobject> {
85
  static const bool value = true;
86
};
87
88
} // namespace llvm
89
90
#endif // LLVM_CLANG_AST_BASESUBOBJECT_H