clang  6.0.0svn
BaseSubobject.h
Go to the documentation of this file.
1 //===--- BaseSubobject.h - BaseSubobject class ----------------------------===//
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/DenseMap.h"
20 #include "llvm/Support/DataTypes.h"
21 #include "llvm/Support/type_traits.h"
22 
23 namespace clang {
24 // BaseSubobject - Uniquely identifies a direct or indirect base class.
25 // Stores both the base class decl and the offset from the most derived class to
26 // the base class. Used for vtable and VTT generation.
28  /// Base - The base class declaration.
29  const CXXRecordDecl *Base;
30 
31  /// BaseOffset - The offset from the most derived class to the base class.
32  CharUnits BaseOffset;
33 
34 public:
36  BaseSubobject(const CXXRecordDecl *Base, CharUnits BaseOffset)
37  : Base(Base), BaseOffset(BaseOffset) { }
38 
39  /// getBase - Returns the base class declaration.
40  const CXXRecordDecl *getBase() const { return Base; }
41 
42  /// getBaseOffset - Returns the base class offset.
43  CharUnits getBaseOffset() const { return BaseOffset; }
44 
45  friend bool operator==(const BaseSubobject &LHS, const BaseSubobject &RHS) {
46  return LHS.Base == RHS.Base && LHS.BaseOffset == RHS.BaseOffset;
47  }
48 };
49 
50 } // end namespace clang
51 
52 namespace llvm {
53 
54 template<> struct DenseMapInfo<clang::BaseSubobject> {
56  return clang::BaseSubobject(
59  }
60 
62  return clang::BaseSubobject(
65  }
66 
67  static unsigned getHashValue(const clang::BaseSubobject &Base) {
68  typedef std::pair<const clang::CXXRecordDecl *, clang::CharUnits> PairTy;
69  return DenseMapInfo<PairTy>::getHashValue(PairTy(Base.getBase(),
70  Base.getBaseOffset()));
71  }
72 
73  static bool isEqual(const clang::BaseSubobject &LHS,
74  const clang::BaseSubobject &RHS) {
75  return LHS == RHS;
76  }
77 };
78 
79 // It's OK to treat BaseSubobject as a POD type.
80 template <> struct isPodLike<clang::BaseSubobject> {
81  static const bool value = true;
82 };
83 
84 }
85 
86 #endif
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:26
CharUnits getBaseOffset() const
getBaseOffset - Returns the base class offset.
Definition: BaseSubobject.h:43
static bool isEqual(const clang::BaseSubobject &LHS, const clang::BaseSubobject &RHS)
Definition: BaseSubobject.h:73
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:45
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:40
static clang::BaseSubobject getTombstoneKey()
Definition: BaseSubobject.h:61
BaseSubobject(const CXXRecordDecl *Base, CharUnits BaseOffset)
Definition: BaseSubobject.h:36
static unsigned getHashValue(const clang::BaseSubobject &Base)
Definition: BaseSubobject.h:67
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:55
Represents a C++ struct/union/class.
Definition: DeclCXX.h:266