Skip to content

Commit 367e99e

Browse files
authored
Revert "Revert "[clang][Interp] Improve "in call to" call argument printing"" (#102786)
Reverts #102785
1 parent b8fc97f commit 367e99e

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

clang/lib/AST/Interp/InterpFrame.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ void InterpFrame::popArgs() {
102102
}
103103

104104
template <typename T>
105-
static void print(llvm::raw_ostream &OS, const T &V, ASTContext &, QualType) {
106-
OS << V;
105+
static void print(llvm::raw_ostream &OS, const T &V, ASTContext &ASTCtx,
106+
QualType Ty) {
107+
V.toAPValue(ASTCtx).printPretty(OS, ASTCtx, Ty);
107108
}
108109

109110
template <>

clang/test/AST/Interp/constexpr-frame-describe.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,18 @@ static_assert(bar.fail2<int*, 42>()); // both-error {{constant expression}} \
8181
static_assert(bar.fail3(3, 4UL, bar, &bar)); // both-error {{constant expression}} \
8282
// expected-note {{in call to 'bar.fail3<int, unsigned long, Bar<int>, const Bar<int> *>(3, 4, &bar, &bar)'}} \
8383
// ref-note {{in call to 'bar.fail3<int, unsigned long, Bar<int>, const Bar<int> *>(3, 4, {}, &bar)'}}
84+
85+
86+
87+
/// FIXME: Bound member pointer printing doesn't work right, see the last parameter to MemPtr().
88+
struct MemPtrTest {
89+
int n;
90+
void f();
91+
};
92+
MemPtrTest mpt; // both-note {{here}}
93+
constexpr int MemPtr(int (MemPtrTest::*a), void (MemPtrTest::*b)(), int &c) {
94+
return c; // both-note {{read of non-constexpr variable 'mpt'}}
95+
}
96+
static_assert(MemPtr(&MemPtrTest::n, &MemPtrTest::f, mpt.*&MemPtrTest::n), ""); // both-error {{constant expression}} \
97+
// expected-note {{in call to 'MemPtr(&MemPtrTest::n, &MemPtrTest::f, mpt)'}} \
98+
// ref-note {{in call to 'MemPtr(&MemPtrTest::n, &MemPtrTest::f, mpt.n)'}}

0 commit comments

Comments
 (0)