[clang] f007c99 - [clang][Interp] Fix InterpFrame::describe() for This pointers
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 25 23:55:28 PDT 2022
Author: Timm Bäder
Date: 2022-10-26T08:48:55+02:00
New Revision: f007c99ed12f15f23e39f02d0fcb71eecead9b97
URL: https://github.com/llvm/llvm-project/commit/f007c99ed12f15f23e39f02d0fcb71eecead9b97
DIFF: https://github.com/llvm/llvm-project/commit/f007c99ed12f15f23e39f02d0fcb71eecead9b97.diff
LOG: [clang][Interp] Fix InterpFrame::describe() for This pointers
Since we pass this via the stack, we need to account for it when
desribing the stack frame (parameters). This fixes a previously
commented-out test case.
Differential Revision: https://reviews.llvm.org/D136670
Added:
Modified:
clang/lib/AST/Interp/InterpFrame.cpp
clang/test/AST/Interp/records.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/InterpFrame.cpp b/clang/lib/AST/Interp/InterpFrame.cpp
index 427de28f2419..1a97e2ad02b4 100644
--- a/clang/lib/AST/Interp/InterpFrame.cpp
+++ b/clang/lib/AST/Interp/InterpFrame.cpp
@@ -149,7 +149,11 @@ void InterpFrame::describe(llvm::raw_ostream &OS) {
OS << "->";
}
OS << *F << "(";
- unsigned Off = Func->hasRVO() ? primSize(PT_Ptr) : 0;
+ unsigned Off = 0;
+
+ Off += Func->hasRVO() ? primSize(PT_Ptr) : 0;
+ Off += Func->hasThisPointer() ? primSize(PT_Ptr) : 0;
+
for (unsigned I = 0, N = F->getNumParams(); I < N; ++I) {
QualType Ty = F->getParamDecl(I)->getType();
diff --git a/clang/test/AST/Interp/records.cpp b/clang/test/AST/Interp/records.cpp
index 3edc0d89b29c..18caf5d8f4f0 100644
--- a/clang/test/AST/Interp/records.cpp
+++ b/clang/test/AST/Interp/records.cpp
@@ -257,11 +257,6 @@ namespace DeriveFailures {
static_assert(D.Val == 0, ""); // ref-error {{not an integral constant expression}} \
// ref-note {{initializer of 'D' is not a constant expression}}
-#if 0
- // FIXME: This test is currently disabled because the failing constructor call
- // causes us to run into an assertion later on in the new interpreter.
- // Once that is fixed, we fail successfully but the diagnostic uses the
- // wrong value.
struct AnotherBase {
int Val;
constexpr AnotherBase(int i) : Val(12 / i) {} //ref-note {{division by zero}} \
@@ -274,9 +269,7 @@ namespace DeriveFailures {
constexpr AnotherBase Derp(0); // ref-error {{must be initialized by a constant expression}} \
// ref-note {{in call to 'AnotherBase(0)'}} \
// expected-error {{must be initialized by a constant expression}} \
- // expected-note {{in call to 'AnotherBase(}}
- // FIXME Previous note uses the wrong value
-#endif
+ // expected-note {{in call to 'AnotherBase(0)'}}
struct YetAnotherBase {
int Val;
More information about the cfe-commits
mailing list