[clang] 9a82158 - [clang][bytecode] Fix a mishap in HasPtrField calculation (#184557)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 3 23:59:27 PST 2026
Author: Timm Baeder
Date: 2026-03-04T08:59:23+01:00
New Revision: 9a821584a5165809fdfeffdb086d398e7a66e101
URL: https://github.com/llvm/llvm-project/commit/9a821584a5165809fdfeffdb086d398e7a66e101
DIFF: https://github.com/llvm/llvm-project/commit/9a821584a5165809fdfeffdb086d398e7a66e101.diff
LOG: [clang][bytecode] Fix a mishap in HasPtrField calculation (#184557)
The Record constructor has a parameter and a class member of the same
name. Also include composite array element types in the calculation in
Program.cpp.
Added:
Modified:
clang/lib/AST/ByteCode/Program.cpp
clang/lib/AST/ByteCode/Record.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ByteCode/Program.cpp b/clang/lib/AST/ByteCode/Program.cpp
index 7eebb303d8553..7364e9405efe2 100644
--- a/clang/lib/AST/ByteCode/Program.cpp
+++ b/clang/lib/AST/ByteCode/Program.cpp
@@ -376,14 +376,16 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) {
Desc = createDescriptor(FD, *T, nullptr, std::nullopt, IsConst,
/*isTemporary=*/false, IsMutable, IsVolatile);
HasPtrField = HasPtrField || (T == PT_Ptr);
+ } else if ((Desc = createDescriptor(
+ FD, FT.getTypePtr(), std::nullopt, IsConst,
+ /*isTemporary=*/false, IsMutable, IsVolatile))) {
+ HasPtrField =
+ HasPtrField ||
+ (Desc->isPrimitiveArray() && Desc->getPrimType() == PT_Ptr) ||
+ (Desc->ElemRecord && Desc->ElemRecord->hasPtrField());
} else {
- Desc = createDescriptor(FD, FT.getTypePtr(), std::nullopt, IsConst,
- /*isTemporary=*/false, IsMutable, IsVolatile);
- HasPtrField = HasPtrField || (Desc && Desc->isPrimitiveArray() &&
- Desc->getPrimType() == PT_Ptr);
- }
- if (!Desc)
return nullptr;
+ }
Fields.emplace_back(FD, Desc, BaseSize);
BaseSize += align(Desc->getAllocSize());
}
diff --git a/clang/lib/AST/ByteCode/Record.cpp b/clang/lib/AST/ByteCode/Record.cpp
index f0ec33f54901c..13a5ffb85787c 100644
--- a/clang/lib/AST/ByteCode/Record.cpp
+++ b/clang/lib/AST/ByteCode/Record.cpp
@@ -24,13 +24,13 @@ Record::Record(const RecordDecl *Decl, BaseList &&SrcBases,
for (Base &B : Bases) {
BaseMap[B.Decl] = &B;
- if (!HasPtrField)
- HasPtrField |= B.R->hasPtrField();
+ if (!this->HasPtrField)
+ this->HasPtrField |= B.R->hasPtrField();
}
for (Base &V : VirtualBases) {
VirtualBaseMap[V.Decl] = &V;
- if (!HasPtrField)
- HasPtrField |= V.R->hasPtrField();
+ if (!this->HasPtrField)
+ this->HasPtrField |= V.R->hasPtrField();
}
}
More information about the cfe-commits
mailing list