[clang] 16853f6 - [clang][bytecode] Variadic ctors also start lifetime (#201113)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 2 07:16:53 PDT 2026
Author: Timm Baeder
Date: 2026-06-02T16:16:47+02:00
New Revision: 16853f627616581293a8561b5c00dad33056c75f
URL: https://github.com/llvm/llvm-project/commit/16853f627616581293a8561b5c00dad33056c75f
DIFF: https://github.com/llvm/llvm-project/commit/16853f627616581293a8561b5c00dad33056c75f.diff
LOG: [clang][bytecode] Variadic ctors also start lifetime (#201113)
This is the same thing we do in the non-variadic `Call()`.
Added:
Modified:
clang/lib/AST/ByteCode/Interp.cpp
clang/test/AST/ByteCode/records.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp
index 6bcebf3ee892b..0ea6de1742175 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1747,7 +1747,8 @@ bool CallVar(InterpState &S, CodePtr OpPC, const Function *Func,
if (!(S.Current->getFunction() &&
S.Current->getFunction()->isLambdaStaticInvoker() &&
Func->isLambdaCallOperator())) {
- if (!CheckInvoke(S, OpPC, ThisPtr))
+ if (!CheckInvoke(S, OpPC, ThisPtr,
+ Func->isConstructor() || Func->isDestructor()))
return false;
}
diff --git a/clang/test/AST/ByteCode/records.cpp b/clang/test/AST/ByteCode/records.cpp
index a9b8ac6b10bcb..b792b56563b2f 100644
--- a/clang/test/AST/ByteCode/records.cpp
+++ b/clang/test/AST/ByteCode/records.cpp
@@ -2031,3 +2031,16 @@ namespace StaticMemberRedecl {
const int S::m = 10;
static_assert(getM() == 10, "");
}
+
+namespace VariadicCtorStartsLifetime {
+ struct S {
+ constexpr S(int, ...) {}
+ };
+ class C {
+ public:
+ S s;
+ constexpr C() : s(1,1) {}
+ };
+ /// Used to not start the lifetime of 's'.
+ constexpr C c;
+}
More information about the cfe-commits
mailing list