Skip to content

Commit 3a089f3

Browse files
committed
Revert "Emit clang-computed sizeof values in refcount"
This reverts commit 2ad45b7.
1 parent 57c0e79 commit 3a089f3

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

‎cpp2rust/converter/models/converter_refcount.cpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,8 +1707,9 @@ bool ConverterRefCount::VisitUnaryExprOrTypeTraitExpr(
17071707
: expr->getArgumentExpr()->getType();
17081708
switch (expr->getKind()) {
17091709
case clang::UnaryExprOrTypeTrait::UETT_SizeOf:
1710-
if (clang::Expr::EvalResult size; expr->EvaluateAsInt(size, ctx_)) {
1711-
StrCat(std::format("{}usize", size.Val.getInt().getZExtValue()));
1710+
// TODO: Once Values are dropped from fields, precomputation should be gone
1711+
if (RustSizeDivergesFromC(arg_type)) {
1712+
StrCat(std::format("{}usize", ctx_.getTypeSize(arg_type) / 8));
17121713
computed_expr_type_ = ComputedExprType::FreshValue;
17131714
return false;
17141715
}

‎tests/unit/types.cpp‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
#include <cstdint>
66
#include <inttypes.h>
77

8-
static_assert(sizeof(std::size_t) == sizeof(void *), "");
9-
static_assert(sizeof(int *) == 8, "");
10-
118
int main() {
129
const uint8_t xu8 = 8;
1310
const uint16_t xu16 = 16;
@@ -28,8 +25,6 @@ int main() {
2825
std::nullptr_t xnp = nullptr;
2926
assert(xu8 + xu16 + xu32 + xu64 + xsz1 + xsz2 + xi1 + xi2 + xi3 + xi4 == 352);
3027
assert(xld * 2 == 3);
31-
int *ip = nullptr;
32-
assert(sizeof(ip) == sizeof(void *));
3328
assert(xwc + xc8 + xc16 + xc32 == 266);
3429
assert(xnp == nullptr);
3530
return 0;

0 commit comments

Comments
 (0)