[clang] [clang][bytecode][NFC] Implement MemberPointer::toDiagnosticString() (PR #106825)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 30 21:55:00 PDT 2024
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/106825
>From fd47ce2d92865a5c9e5307478a10dd2c8b91ac44 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Sat, 31 Aug 2024 02:56:46 +0200
Subject: [PATCH] [clang][bytecode][NFC] Implement
MemberPointer::toDiagnosticString()
---
clang/lib/AST/ByteCode/Interp.h | 2 +-
clang/lib/AST/ByteCode/MemberPointer.h | 12 ++++++------
clang/lib/AST/ByteCode/Opcodes.td | 4 ++--
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index aa790a71a6b476..c1423a060bcb97 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -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;
}
diff --git a/clang/lib/AST/ByteCode/MemberPointer.h b/clang/lib/AST/ByteCode/MemberPointer.h
index de135a40a3c77b..b17ce256e75e29 100644
--- a/clang/lib/AST/ByteCode/MemberPointer.h
+++ b/clang/lib/AST/ByteCode/MemberPointer.h
@@ -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)));
}
@@ -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())
@@ -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 {
diff --git a/clang/lib/AST/ByteCode/Opcodes.td b/clang/lib/AST/ByteCode/Opcodes.td
index f286c71a129d1d..46247688d4ef85 100644
--- a/clang/lib/AST/ByteCode/Opcodes.td
+++ b/clang/lib/AST/ByteCode/Opcodes.td
@@ -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"; }
@@ -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;
More information about the cfe-commits
mailing list