Skip to content

Commit 2988205

Browse files
committed
Address other review comments
1 parent afd8a49 commit 2988205

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

clang/lib/AST/Interp/InterpBitcast.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ static bool CheckBitcastType(InterpState &S, CodePtr OpPC, QualType T,
272272
}
273273

274274
static bool readPointerToBuffer(const Context &Ctx, const Pointer &FromPtr,
275-
BitTracker &Bits, bool RetrnOnUninit) {
275+
BitTracker &Bits, bool ReturnOnUninit) {
276276
const ASTContext &ASTCtx = Ctx.getASTContext();
277277
uint64_t PointerSizeInBits =
278278
ASTCtx.getTargetInfo().getPointerWidth(LangAS::Default);
@@ -284,7 +284,7 @@ static bool readPointerToBuffer(const Context &Ctx, const Pointer &FromPtr,
284284
if (!P.isInitialized()) {
285285
Bits.markUninitializedUntil(BitOffset +
286286
(primSize(T) * 8)); /// primSize() usage.
287-
return RetrnOnUninit;
287+
return ReturnOnUninit;
288288
}
289289

290290
assert(P.isInitialized());
@@ -337,7 +337,8 @@ bool DoBitCast(InterpState &S, CodePtr OpPC, const Pointer &P, std::byte *Buff,
337337
bool BigEndian = ASTCtx.getTargetInfo().isBigEndian();
338338

339339
BitTracker Bits;
340-
bool Success = readPointerToBuffer(S.getContext(), P, Bits, false);
340+
bool Success =
341+
readPointerToBuffer(S.getContext(), P, Bits, /*ReturnOnUninit=*/false);
341342

342343
Bits.markUninitializedUntil(BuffSize * 8);
343344
assert(Bits.size() == BuffSize * 8);
@@ -350,13 +351,9 @@ bool DoBitCast(InterpState &S, CodePtr OpPC, const Pointer &P, std::byte *Buff,
350351
return Success; // && !HasIndeterminateBits;
351352
}
352353

353-
// This function is constexpr if and only if To, From, and the types of
354-
// all subobjects of To and From are types T such that...
355-
// (3.1) - is_union_v<T> is false;
356-
// (3.2) - is_pointer_v<T> is false;
357-
// (3.3) - is_member_pointer_v<T> is false;
358-
// (3.4) - is_volatile_v<T> is false; and
359-
// (3.5) - T has no non-static data members of reference type
354+
/// Bitcast from a Pointer to a Pointer.
355+
/// We read all fields from \p P into a buffer, then iterate
356+
/// over the fields of \p DestPtr and read from the buffer.
360357
bool DoBitCastToPtr(InterpState &S, const Pointer &P, Pointer &DestPtr,
361358
CodePtr OpPC) {
362359
assert(P.isLive());
@@ -376,7 +373,7 @@ bool DoBitCastToPtr(InterpState &S, const Pointer &P, Pointer &DestPtr,
376373
bool BigEndian = ASTCtx.getTargetInfo().isBigEndian();
377374

378375
BitTracker Bytes;
379-
if (!readPointerToBuffer(Ctx, P, Bytes, true))
376+
if (!readPointerToBuffer(Ctx, P, Bytes, /*ReturnOnUninit=*/true))
380377
return false;
381378

382379
bool Success = enumeratePointerFields(

0 commit comments

Comments
 (0)