clang: lib/AST/ByteCode/MemberPointer.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_CLANG_AST_INTERP_MEMBER_POINTER_H
10#define LLVM_CLANG_AST_INTERP_MEMBER_POINTER_H
11
13#include
14
16class ASTContext;
17namespace interp {
18
19class Context;
20class FunctionPointer;
21
23private:
26 int32_t PtrOffset = 0;
27
29 : Base(Base), Dcl(Dcl), PtrOffset(PtrOffset) {}
30
31public:
35
36 assert(Address == 0);
37 }
38
40 assert((isa<FieldDecl, IndirectFieldDecl, CXXMethodDecl>(D)));
41 }
42
44 assert(
45 false &&
46 "getIntegerRepresentation() shouldn't be reachable for MemberPointers");
47 return 17;
48 }
49
51
53
55 if (PtrOffset < 0)
56 return Base.atField(-PtrOffset);
57 return Base.atFieldSub(PtrOffset);
58 }
60 return isa_and_nonnull(Dcl);
61 }
63 return dyn_cast_if_present(Dcl);
64 }
66 return dyn_cast_if_present(Dcl);
67 }
68
69 bool hasDecl() const { return Dcl; }
71
73 if (Base.isZero())
75 return MemberPointer(this->Base, Dcl, Offset + PtrOffset);
76 }
77
79 assert(this->Base.isZero());
80 return MemberPointer(Instance, this->Dcl, this->PtrOffset);
81 }
82
84
85 bool isZero() const { return Base.isZero() && !Dcl; }
89 return MF->isWeak();
90 return false;
91 }
92
93 void print(llvm::raw_ostream &OS) const {
94 OS << "MemberPtr(" << Base << " " << (const void *)Dcl << " + " << PtrOffset
95 << ")";
96 }
97
100 }
101
103 if (this->Dcl == RHS.Dcl)
106 }
107};
108
111 return OS;
112}
113
114}
115}
116
117#endif
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
std::string getAsString(const ASTContext &Ctx, QualType Ty) const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Represents a static or instance method of a struct/union/class.
Represents a member of a struct/union/class.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Holds all information required to evaluate constexpr code in a module.
const ValueDecl * getDecl() const
APValue toAPValue(const ASTContext &) const
uint64_t getIntegerRepresentation() const
MemberPointer takeInstance(Pointer Instance) const
std::string toDiagnosticString(const ASTContext &Ctx) const
MemberPointer(uint32_t Address, const Descriptor *D)
bool isMemberFunctionPointer() const
MemberPointer(const ValueDecl *D)
const FieldDecl * getField() const
void print(llvm::raw_ostream &OS) const
MemberPointer atInstanceBase(unsigned Offset) const
ComparisonCategoryResult compare(const MemberPointer &RHS) const
FunctionPointer toFunctionPointer(const Context &Ctx) const
const CXXMethodDecl * getMemberFunction() const
std::optional< Pointer > toPointer(const Context &Ctx) const
MemberPointer(Pointer Base, const ValueDecl *Dcl)
A pointer to a memory block, live or dead.
bool isZero() const
Checks if the pointer is null.
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const Boolean &B)
The JSON file list parser is used to communicate input to InstallAPI.
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
Describes a memory block created by an allocation site.