[PATCH] D142630: [clang][Interp] Implement virtual function calls
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 14 04:51:02 PST 2023
tbaeder added inline comments.
================
Comment at: clang/lib/AST/Interp/Interp.h:1560
+ // is the furthest we might go up in the hierarchy.
+ ThisPtr = ThisPtr.getDeclPtr();
+ }
----------------
I think this test case was from the function pointer review, but this fixes:
```
struct S {
virtual constexpr int func() const { return 1; }
};
struct Middle : S {
constexpr Middle(int i) : i(i) {}
int i;
};
struct Other {
constexpr Other(int k) : k(k) {}
int k;
};
struct S2 : Middle, Other {
int j;
constexpr S2(int i, int j, int k) : Middle(i), Other(k), j(j) {}
virtual constexpr int func() const { return i + j + k + S::func(); }
};
constexpr S s;
constexpr decltype(&S::func) foo = &S::func;
constexpr S2 s2(1, 2, 3);
constexpr int value3 = (s2.*foo)();
```
even I am confused by all of this now, so the comment might not be the clearest :)
(I did not add that test case since it needs other changes in`classify()` and `VisitBinaryOperator()`, but can do that in a follow-up commit.)
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D142630/new/
https://reviews.llvm.org/D142630
More information about the cfe-commits
mailing list