llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

Fixes https://github.com/llvm/llvm-project/issues/177133

---
Full diff: https://github.com/llvm/llvm-project/pull/177154.diff


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/InterpFrame.cpp (+4-3) 
- (modified) clang/test/AST/ByteCode/cxx26.cpp (+17) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/InterpFrame.cpp 
b/clang/lib/AST/ByteCode/InterpFrame.cpp
index 3b883761ad001..9a0a508faa6d8 100644
--- a/clang/lib/AST/ByteCode/InterpFrame.cpp
+++ b/clang/lib/AST/ByteCode/InterpFrame.cpp
@@ -152,7 +152,7 @@ static bool shouldSkipInBacktrace(const Function *F) {
 
 void InterpFrame::describe(llvm::raw_ostream &OS) const {
   // For lambda static invokers, we would just print __invoke().
-  if (const auto *F = getFunction(); F && shouldSkipInBacktrace(F))
+  if (Func && shouldSkipInBacktrace(Func))
     return;
 
   const Expr *CallExpr = Caller->getExpr(getRetPC());
@@ -189,11 +189,12 @@ void InterpFrame::describe(llvm::raw_ostream &OS) const {
   unsigned Off = 0;
 
   Off += Func->hasRVO() ? primSize(PT_Ptr) : 0;
-  Off += Func->hasThisPointer() ? primSize(PT_Ptr) : 0;
+  Off += (Func->hasThisPointer() && !Func->isThisPointerExplicit())
+             ? primSize(PT_Ptr)
+             : 0;
 
   for (unsigned I = 0, N = F->getNumParams(); I < N; ++I) {
     QualType Ty = F->getParamDecl(I)->getType();
-
     PrimType PrimTy = S.Ctx.classify(Ty).value_or(PT_Ptr);
 
     TYPE_SWITCH(PrimTy, print(OS, stackRef<T>(Off), S.getASTContext(), Ty));
diff --git a/clang/test/AST/ByteCode/cxx26.cpp 
b/clang/test/AST/ByteCode/cxx26.cpp
index 64461ee9e12cd..acab347963923 100644
--- a/clang/test/AST/ByteCode/cxx26.cpp
+++ b/clang/test/AST/ByteCode/cxx26.cpp
@@ -45,3 +45,20 @@ constexpr int a = 12;
 constexpr const int *b = &a;
 constexpr int *f = (int*)(void*)b;
 static_assert(*f == 12);
+
+namespace ExplicitThisInBacktrace {
+  struct S {
+    constexpr void foo(this const S& self) {
+      throw; // both-note {{not valid in a constant expression}}
+    }
+  };
+
+  constexpr bool test() {
+    S s;
+    s.foo(); // both-note {{in call to}}
+    return true;
+  }
+
+  static_assert(test()); // both-error {{not an integral constant expression}} 
\
+                         // both-note {{in call to}}
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/177154
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to