[clang] Revert "Revert "[clang][Interp] Improve "in call to" call argument printing"" (PR #102786)
Vitaly Buka via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 10 20:40:21 PDT 2024
https://github.com/vitalybuka created https://github.com/llvm/llvm-project/pull/102786
Reverts llvm/llvm-project#102785
>From 0066d85186fda169b17acc63e4e85ad901e0cbe4 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at gmail.com>
Date: Sat, 10 Aug 2024 20:40:10 -0700
Subject: [PATCH] =?UTF-8?q?Revert=20"Revert=20"[clang][Interp]=20Improve?=
=?UTF-8?q?=20"in=20call=20to"=20call=20argument=20printing"=20=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit f498638a4cd5f60dafcda512e4de848ee627ab95.
---
clang/lib/AST/Interp/InterpFrame.cpp | 5 +++--
.../test/AST/Interp/constexpr-frame-describe.cpp | 15 +++++++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/clang/lib/AST/Interp/InterpFrame.cpp b/clang/lib/AST/Interp/InterpFrame.cpp
index 27108f957305f3..4530f28d694e84 100644
--- a/clang/lib/AST/Interp/InterpFrame.cpp
+++ b/clang/lib/AST/Interp/InterpFrame.cpp
@@ -102,8 +102,9 @@ void InterpFrame::popArgs() {
}
template <typename T>
-static void print(llvm::raw_ostream &OS, const T &V, ASTContext &, QualType) {
- OS << V;
+static void print(llvm::raw_ostream &OS, const T &V, ASTContext &ASTCtx,
+ QualType Ty) {
+ V.toAPValue(ASTCtx).printPretty(OS, ASTCtx, Ty);
}
template <>
diff --git a/clang/test/AST/Interp/constexpr-frame-describe.cpp b/clang/test/AST/Interp/constexpr-frame-describe.cpp
index e039fd61ae9812..a0ae046fc01786 100644
--- a/clang/test/AST/Interp/constexpr-frame-describe.cpp
+++ b/clang/test/AST/Interp/constexpr-frame-describe.cpp
@@ -81,3 +81,18 @@ static_assert(bar.fail2<int*, 42>()); // both-error {{constant expression}} \
static_assert(bar.fail3(3, 4UL, bar, &bar)); // both-error {{constant expression}} \
// expected-note {{in call to 'bar.fail3<int, unsigned long, Bar<int>, const Bar<int> *>(3, 4, &bar, &bar)'}} \
// ref-note {{in call to 'bar.fail3<int, unsigned long, Bar<int>, const Bar<int> *>(3, 4, {}, &bar)'}}
+
+
+
+/// FIXME: Bound member pointer printing doesn't work right, see the last parameter to MemPtr().
+struct MemPtrTest {
+ int n;
+ void f();
+};
+MemPtrTest mpt; // both-note {{here}}
+constexpr int MemPtr(int (MemPtrTest::*a), void (MemPtrTest::*b)(), int &c) {
+ return c; // both-note {{read of non-constexpr variable 'mpt'}}
+}
+static_assert(MemPtr(&MemPtrTest::n, &MemPtrTest::f, mpt.*&MemPtrTest::n), ""); // both-error {{constant expression}} \
+ // expected-note {{in call to 'MemPtr(&MemPtrTest::n, &MemPtrTest::f, mpt)'}} \
+ // ref-note {{in call to 'MemPtr(&MemPtrTest::n, &MemPtrTest::f, mpt.n)'}}
More information about the cfe-commits
mailing list