https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/177154
>From 0c105af8b293b6cafe0a5ba0325cca4febf13784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Wed, 21 Jan 2026 13:34:58 +0100 Subject: [PATCH] [clang][bytecode] Fix a crash with explicit this parameters Fixes https://github.com/llvm/llvm-project/issues/177133 --- clang/lib/AST/ByteCode/InterpFrame.cpp | 7 ++++--- clang/test/AST/ByteCode/cxx26.cpp | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/clang/lib/AST/ByteCode/InterpFrame.cpp b/clang/lib/AST/ByteCode/InterpFrame.cpp index 5d645feb5579d..b92dfbe0b1138 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,13 +189,14 @@ 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; llvm::ListSeparator Comma; for (unsigned I = 0, N = F->getNumParams(); I < N; ++I) { OS << Comma; 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}} +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
