[clang] 20506a0 - [clang][bytecode] Fix operator new source expression (#126870)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 12 01:05:54 PST 2025
Author: Timm Baeder
Date: 2025-02-12T10:05:49+01:00
New Revision: 20506a0a15f9c4a7dc1cd0b4fa2dec8449074ab8
URL: https://github.com/llvm/llvm-project/commit/20506a0a15f9c4a7dc1cd0b4fa2dec8449074ab8
DIFF: https://github.com/llvm/llvm-project/commit/20506a0a15f9c4a7dc1cd0b4fa2dec8449074ab8.diff
LOG: [clang][bytecode] Fix operator new source expression (#126870)
... for composite element types. Looks like I forgot this in
e6030d389571b3f1b0f0c5a35b7fa45937ed0f6c
Added:
Modified:
clang/lib/AST/ByteCode/InterpBuiltin.cpp
clang/test/AST/ByteCode/new-delete.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 0e586725b5869..55ac41736344d 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1683,7 +1683,7 @@ static bool interp__builtin_operator_new(InterpState &S, CodePtr OpPC,
assert(!ElemT);
// Structs etc.
const Descriptor *Desc = S.P.createDescriptor(
- Call, ElemType.getTypePtr(), Descriptor::InlineDescMD,
+ NewCall, ElemType.getTypePtr(), Descriptor::InlineDescMD,
/*IsConst=*/false, /*IsTemporary=*/false, /*IsMutable=*/false,
/*Init=*/nullptr);
diff --git a/clang/test/AST/ByteCode/new-delete.cpp b/clang/test/AST/ByteCode/new-delete.cpp
index e60ff894c9715..31f066b37858d 100644
--- a/clang/test/AST/ByteCode/new-delete.cpp
+++ b/clang/test/AST/ByteCode/new-delete.cpp
@@ -840,10 +840,17 @@ template <typename T>
struct SS {
constexpr SS(unsigned long long N)
: data(nullptr){
- data = alloc.allocate(N); // #call
+ data = alloc.allocate(N);
for(std::size_t i = 0; i < N; i ++)
- std::construct_at<T>(data + i, i); // #construct_call
+ std::construct_at<T>(data + i, i);
}
+
+ constexpr SS()
+ : data(nullptr){
+ data = alloc.allocate(1);
+ std::construct_at<T>(data);
+ }
+
constexpr T operator[](std::size_t i) const {
return data[i];
}
@@ -855,6 +862,7 @@ struct SS {
T* data;
};
constexpr unsigned short ssmall = SS<unsigned short>(100)[42];
+constexpr auto Ss = SS<S>()[0];
More information about the cfe-commits
mailing list