[PATCH] D136670: [clang][Interp] Fix InterpFrame::describe() for This pointers

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 25 02:15:17 PDT 2022


tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

  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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136670

Files:
  clang/lib/AST/Interp/InterpFrame.cpp
  clang/test/AST/Interp/records.cpp


Index: clang/test/AST/Interp/records.cpp
===================================================================
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -281,11 +281,6 @@
   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}} \
@@ -298,9 +293,7 @@
   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;
Index: clang/lib/AST/Interp/InterpFrame.cpp
===================================================================
--- clang/lib/AST/Interp/InterpFrame.cpp
+++ clang/lib/AST/Interp/InterpFrame.cpp
@@ -142,7 +142,11 @@
     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();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136670.470422.patch
Type: text/x-patch
Size: 1932 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221025/036a08d9/attachment.bin>


More information about the cfe-commits mailing list