[all-commits] [llvm/llvm-project] 3a1d8a: [clang-repl] Fix Value::setRawBits unit confusion ...
Vassil Vassilev via All-commits
all-commits at lists.llvm.org
Thu Jun 4 06:16:31 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 3a1d8a8db2645a2a62b4f13916e2ba6e639a7fad
https://github.com/llvm/llvm-project/commit/3a1d8a8db2645a2a62b4f13916e2ba6e639a7fad
Author: Vassil Vassilev <v.g.vassilev at gmail.com>
Date: 2026-06-04 (Thu, 04 Jun 2026)
Changed paths:
M clang/include/clang/Interpreter/Value.h
M clang/lib/Interpreter/InterpreterValuePrinter.cpp
M clang/lib/Interpreter/Value.cpp
M clang/unittests/Interpreter/InterpreterTest.cpp
Log Message:
-----------
[clang-repl] Fix Value::setRawBits unit confusion and right-size raw storage. (#200886)
Value::setRawBits had inconsistent units: the default value and the size
assert treated the parameter as bytes (sizeof(Storage)), while the
memcpy treated it as bits (NBits / 8). A caller passing the natural byte
count (e.g. sizeof(long long)) ended up copying only sizeof(T)/8 bytes
-- one byte for an 8-byte payload, leaving the rest stale. The one
in-tree caller compensated by multiplying by 8, hiding the bug.
Rename the parameter to NBytes and drop the / 8 so the API name,
default, assert, and memcpy all agree on bytes. Update the caller in
InterpreterValuePrinter.cpp to pass ElemSize directly.
Right-size the Storage::m_RawBits array while we are here: it was
sizeof(long double) * 8 bytes, which reads like a bit/byte confusion
since the widest typed member of the union is long double itself. The
oversized array made sizeof(Value) ~144 bytes on x86_64 instead of ~40,
bloating every copy/move of a Value.
Add a regression test exercising setRawBits with both an explicit byte
count and the default argument. Pre-fix the test fails for both: the
explicit-count branch copies 1 byte instead of 8, and the default branch
copies sizeof(Storage)/8 bytes instead of the full union width.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list