File indexing completed on 2026-05-10 08:36:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_CLANG_AST_BASESUBOBJECT_H
0014 #define LLVM_CLANG_AST_BASESUBOBJECT_H
0015
0016 #include "clang/AST/CharUnits.h"
0017 #include "clang/AST/DeclCXX.h"
0018 #include "llvm/ADT/DenseMapInfo.h"
0019 #include "llvm/Support/type_traits.h"
0020 #include <cstdint>
0021 #include <utility>
0022
0023 namespace clang {
0024
0025 class CXXRecordDecl;
0026
0027
0028
0029
0030 class BaseSubobject {
0031
0032 const CXXRecordDecl *Base;
0033
0034
0035 CharUnits BaseOffset;
0036
0037 public:
0038 BaseSubobject() = default;
0039 BaseSubobject(const CXXRecordDecl *Base, CharUnits BaseOffset)
0040 : Base(Base), BaseOffset(BaseOffset) {}
0041
0042
0043 const CXXRecordDecl *getBase() const { return Base; }
0044
0045
0046 CharUnits getBaseOffset() const { return BaseOffset; }
0047
0048 friend bool operator==(const BaseSubobject &LHS, const BaseSubobject &RHS) {
0049 return LHS.Base == RHS.Base && LHS.BaseOffset == RHS.BaseOffset;
0050 }
0051 };
0052
0053 }
0054
0055 namespace llvm {
0056
0057 template<> struct DenseMapInfo<clang::BaseSubobject> {
0058 static clang::BaseSubobject getEmptyKey() {
0059 return clang::BaseSubobject(
0060 DenseMapInfo<const clang::CXXRecordDecl *>::getEmptyKey(),
0061 clang::CharUnits::fromQuantity(DenseMapInfo<int64_t>::getEmptyKey()));
0062 }
0063
0064 static clang::BaseSubobject getTombstoneKey() {
0065 return clang::BaseSubobject(
0066 DenseMapInfo<const clang::CXXRecordDecl *>::getTombstoneKey(),
0067 clang::CharUnits::fromQuantity(DenseMapInfo<int64_t>::getTombstoneKey()));
0068 }
0069
0070 static unsigned getHashValue(const clang::BaseSubobject &Base) {
0071 using PairTy = std::pair<const clang::CXXRecordDecl *, clang::CharUnits>;
0072
0073 return DenseMapInfo<PairTy>::getHashValue(PairTy(Base.getBase(),
0074 Base.getBaseOffset()));
0075 }
0076
0077 static bool isEqual(const clang::BaseSubobject &LHS,
0078 const clang::BaseSubobject &RHS) {
0079 return LHS == RHS;
0080 }
0081 };
0082
0083 }
0084
0085 #endif