[clang] [clang][bytecode][NFC] Implement MemberPointer::toDiagnosticString() (PR #106825)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 30 21:26:02 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/106825.diff
3 Files Affected:
- (modified) clang/lib/AST/ByteCode/Interp.h (+2-2)
- (modified) clang/lib/AST/ByteCode/MemberPointer.h (+6-6)
- (modified) clang/lib/AST/ByteCode/Opcodes.td (+2-2)
``````````diff
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index aa790a71a6b476..13884ad6f64b63 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -1045,7 +1045,7 @@ inline bool CmpHelperEQ<MemberPointer>(InterpState &S, CodePtr OpPC,
if (MP.isWeak()) {
const SourceInfo &Loc = S.Current->getSource(OpPC);
S.FFDiag(Loc, diag::note_constexpr_mem_pointer_weak_comparison)
- << MP.getMemberFunction();
+ << MP.toDiagnosticString(S.getASTContext());
return false;
}
}
@@ -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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/106825
More information about the cfe-commits
mailing list