clang  8.0.0
BaseSubobject.h
Go to the documentation of this file.
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 "clang/AST/DeclCXX.h"
19 #include "llvm/ADT/DenseMapInfo.h"
20 #include "llvm/Support/type_traits.h"
21 #include <cstdint>
22 #include <utility>
23 
24 namespace clang {
25 
26 class CXXRecordDecl;
27 
28 // BaseSubobject - Uniquely identifies a direct or indirect base class.
29 // Stores both the base class decl and the offset from the most derived class to
30 // the base class. Used for vtable and VTT generation.
32  /// Base - The base class declaration.
33  const CXXRecordDecl *Base;
34 
35  /// BaseOffset - The offset from the most derived class to the base class.
36  CharUnits BaseOffset;
37 
38 public:
39  BaseSubobject() = default;
40  BaseSubobject(const CXXRecordDecl *Base, CharUnits BaseOffset)
41  : Base(Base), BaseOffset(BaseOffset) {}
42 
43  /// getBase - Returns the base class declaration.
44  const CXXRecordDecl *getBase() const { return Base; }
45 
46  /// getBaseOffset - Returns the base class offset.
47  CharUnits getBaseOffset() const { return BaseOffset; }
48 
49  friend bool operator==(const BaseSubobject &LHS, const BaseSubobject &RHS) {
50  return LHS.Base == RHS.Base && LHS.BaseOffset == RHS.BaseOffset;
51  }
52 };
53 
54 } // namespace clang
55 
56 namespace llvm {
57 
58 template<> struct DenseMapInfo<clang::BaseSubobject> {
60  return clang::BaseSubobject(
63  }
64 
66  return clang::BaseSubobject(
69  }
70 
71  static unsigned getHashValue(const clang::BaseSubobject &Base) {
72  using PairTy = std::pair<const clang::CXXRecordDecl *, clang::CharUnits>;
73 
74  return DenseMapInfo<PairTy>::getHashValue(PairTy(Base.getBase(),
75  Base.getBaseOffset()));
76  }
77 
78  static bool isEqual(const clang::BaseSubobject &LHS,
79  const clang::BaseSubobject &RHS) {
80  return LHS == RHS;
81  }
82 };
83 
84 // It's OK to treat BaseSubobject as a POD type.
85 template <> struct isPodLike<clang::BaseSubobject> {
86  static const bool value = true;
87 };
88 
89 } // namespace llvm
90 
91 #endif // LLVM_CLANG_AST_BASESUBOBJECT_H
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:30
CharUnits getBaseOffset() const
getBaseOffset - Returns the base class offset.
Definition: BaseSubobject.h:47
static bool isEqual(const clang::BaseSubobject &LHS, const clang::BaseSubobject &RHS)
Definition: BaseSubobject.h:78
CharUnits - This is an opaque type for sizes expressed in character units.
Definition: CharUnits.h:38
friend bool operator==(const BaseSubobject &LHS, const BaseSubobject &RHS)
Definition: BaseSubobject.h:49
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
Definition: CharUnits.h:63
const CXXRecordDecl * getBase() const
getBase - Returns the base class declaration.
Definition: BaseSubobject.h:44
static clang::BaseSubobject getTombstoneKey()
Definition: BaseSubobject.h:65
BaseSubobject(const CXXRecordDecl *Base, CharUnits BaseOffset)
Definition: BaseSubobject.h:40
static unsigned getHashValue(const clang::BaseSubobject &Base)
Definition: BaseSubobject.h:71
Dataflow Directional Tag Classes.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
static clang::BaseSubobject getEmptyKey()
Definition: BaseSubobject.h:59
Represents a C++ struct/union/class.
Definition: DeclCXX.h:300