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

via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 30 22:26:05 PDT 2024


Author: Timm Baeder
Date: 2024-08-31T07:26:02+02:00
New Revision: 6f81c878ecd40acf1a0364e0ea5c9e6ea87407a2

URL: https://github.com/llvm/llvm-project/commit/6f81c878ecd40acf1a0364e0ea5c9e6ea87407a2
DIFF: https://github.com/llvm/llvm-project/commit/6f81c878ecd40acf1a0364e0ea5c9e6ea87407a2.diff

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

Added: 
    

Modified: 
    clang/lib/AST/ByteCode/Interp.h
    clang/lib/AST/ByteCode/MemberPointer.h
    clang/lib/AST/ByteCode/Opcodes.td

Removed: 
    


################################################################################
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