Coverage Report

Created: 2019-06-16 23:17

/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
// 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
// This file provides a definition of the BaseSubobject class.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_CLANG_AST_BASESUBOBJECT_H
14
#define LLVM_CLANG_AST_BASESUBOBJECT_H
15
16
#include "clang/AST/CharUnits.h"
17
#include "clang/AST/DeclCXX.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
6.68k
  BaseSubobject() = default;
39
  BaseSubobject(const CXXRecordDecl *Base, CharUnits BaseOffset)
40
292k
      : Base(Base), BaseOffset(BaseOffset) {}
41
42
  /// getBase - Returns the base class declaration.
43
249k
  const CXXRecordDecl *getBase() const { return Base; }
44
45
  /// getBaseOffset - Returns the base class offset.
46
317k
  CharUnits getBaseOffset() const { return BaseOffset; }
47
48
1.03M
  friend bool operator==(const BaseSubobject &LHS, const BaseSubobject &RHS) {
49
1.03M
    return LHS.Base == RHS.Base && 
LHS.BaseOffset == RHS.BaseOffset947k
;
50
1.03M
 }
51
};
52
53
} // namespace clang
54
55
namespace llvm {
56
57
template<> struct DenseMapInfo<clang::BaseSubobject> {
58
87.2k
  static clang::BaseSubobject getEmptyKey() {
59
87.2k
    return clang::BaseSubobject(
60
87.2k
      DenseMapInfo<const clang::CXXRecordDecl *>::getEmptyKey(),
61
87.2k
      clang::CharUnits::fromQuantity(DenseMapInfo<int64_t>::getEmptyKey()));
62
87.2k
  }
63
64
53.7k
  static clang::BaseSubobject getTombstoneKey() {
65
53.7k
    return clang::BaseSubobject(
66
53.7k
      DenseMapInfo<const clang::CXXRecordDecl *>::getTombstoneKey(),
67
53.7k
      clang::CharUnits::fromQuantity(DenseMapInfo<int64_t>::getTombstoneKey()));
68
53.7k
  }
69
70
35.1k
  static unsigned getHashValue(const clang::BaseSubobject &Base) {
71
35.1k
    using PairTy = std::pair<const clang::CXXRecordDecl *, clang::CharUnits>;
72
35.1k
73
35.1k
    return DenseMapInfo<PairTy>::getHashValue(PairTy(Base.getBase(),
74
35.1k
                                                     Base.getBaseOffset()));
75
35.1k
  }
76
77
  static bool isEqual(const clang::BaseSubobject &LHS,
78
1.03M
                      const clang::BaseSubobject &RHS) {
79
1.03M
    return LHS == RHS;
80
1.03M
  }
81
};
82
83
} // namespace llvm
84
85
#endif // LLVM_CLANG_AST_BASESUBOBJECT_H