Skip to content

[clang][bytecode][NFC] Implement MemberPointer::toDiagnosticString() #106825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/AST/ByteCode/Interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2828,7 +2828,7 @@ inline bool GetIntPtr(InterpState &S, CodePtr OpPC, const Descriptor *Desc) {
return true;
}

inline bool GetMemberPtr(InterpState &S, CodePtr OpPC, const Decl *D) {
inline bool GetMemberPtr(InterpState &S, CodePtr OpPC, const ValueDecl *D) {
S.Stk.push<MemberPointer>(D);
return true;
}
Expand Down
12 changes: 6 additions & 6 deletions clang/lib/AST/ByteCode/MemberPointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ class FunctionPointer;
class MemberPointer final {
private:
Pointer Base;
const Decl *Dcl = nullptr;
const ValueDecl *Dcl = nullptr;
int32_t PtrOffset = 0;

MemberPointer(Pointer Base, const Decl *Dcl, int32_t PtrOffset)
MemberPointer(Pointer Base, const ValueDecl *Dcl, int32_t PtrOffset)
: Base(Base), Dcl(Dcl), PtrOffset(PtrOffset) {}

public:
MemberPointer() = default;
MemberPointer(Pointer Base, const Decl *Dcl) : Base(Base), Dcl(Dcl) {}
MemberPointer(Pointer Base, const ValueDecl *Dcl) : Base(Base), Dcl(Dcl) {}
MemberPointer(uint32_t Address, const Descriptor *D) {
// We only reach this for Address == 0, when creating a null member pointer.
assert(Address == 0);
}

MemberPointer(const Decl *D) : Dcl(D) {
MemberPointer(const ValueDecl *D) : Dcl(D) {
assert((isa<FieldDecl, IndirectFieldDecl, CXXMethodDecl>(D)));
}

Expand Down Expand Up @@ -67,7 +67,7 @@ class MemberPointer final {
}

bool hasDecl() const { return Dcl; }
const Decl *getDecl() const { return Dcl; }
const ValueDecl *getDecl() const { return Dcl; }

MemberPointer atInstanceBase(unsigned Offset) const {
if (Base.isZero())
Expand Down Expand Up @@ -96,7 +96,7 @@ class MemberPointer final {
}

std::string toDiagnosticString(const ASTContext &Ctx) const {
return "FIXME";
return toAPValue(Ctx).getAsString(Ctx, Dcl->getType());
}

ComparisonCategoryResult compare(const MemberPointer &RHS) const {
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/ByteCode/Opcodes.td
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def ArgExpr : ArgType { let Name = "const Expr *"; }
def ArgOffsetOfExpr : ArgType { let Name = "const OffsetOfExpr *"; }
def ArgDeclRef : ArgType { let Name = "const DeclRefExpr *"; }
def ArgCCI : ArgType { let Name = "const ComparisonCategoryInfo *"; }
def ArgDecl : ArgType { let Name = "const Decl*"; }
def ArgValueDecl : ArgType { let Name = "const ValueDecl*"; }
def ArgVarDecl : ArgType { let Name = "const VarDecl*"; }
def ArgDesc : ArgType { let Name = "const Descriptor *"; }
def ArgPrimType : ArgType { let Name = "PrimType"; }
Expand Down Expand Up @@ -756,7 +756,7 @@ def Memcpy : Opcode;
def ToMemberPtr : Opcode;
def CastMemberPtrPtr : Opcode;
def GetMemberPtr : Opcode {
let Args = [ArgDecl];
let Args = [ArgValueDecl];
}
def GetMemberPtrBase : Opcode;
def GetMemberPtrDecl : Opcode;
Expand Down
Loading