Skip to content

Commit b0d9c09

Browse files
ChuanqiXu9Axel-Naumann
authored andcommitted
Deserialize LValuePathSerializationHelper's type properly
Close llvm#58716. Tested with libcxx's modules build. When we read the type of LValuePathSerializationHelper, we didn't read the correct type. We read the element type as its name suggests. But the problem here is that it looks like that both the usage and serialization use its type as the top level type. So here is the mismatch. Actually, the type of LValuePathSerializationHelper is never used after Deserialization without the assertion. So it doesn't matter for the release users. And this patch shouldn't change the behavior too. Reviewed By: erichkeane Differential Revision: https://reviews.llvm.org/D139406
1 parent 98a0249 commit b0d9c09

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

clang/include/clang/AST/APValue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class APValue {
238238
}
239239
};
240240
class LValuePathSerializationHelper {
241-
const void *ElemTy;
241+
const void *Ty;
242242

243243
public:
244244
ArrayRef<LValuePathEntry> Path;

clang/include/clang/AST/AbstractBasicReader.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ class DataStreamBasicReader : public BasicReaderBase<Impl> {
190190

191191
APValue::LValuePathSerializationHelper readLValuePathSerializationHelper(
192192
SmallVectorImpl<APValue::LValuePathEntry> &path) {
193-
auto elemTy = asImpl().readQualType();
193+
auto origTy = asImpl().readQualType();
194+
auto elemTy = origTy;
194195
unsigned pathLength = asImpl().readUInt32();
195196
for (unsigned i = 0; i < pathLength; ++i) {
196197
if (elemTy->template getAs<RecordType>()) {
@@ -208,7 +209,7 @@ class DataStreamBasicReader : public BasicReaderBase<Impl> {
208209
APValue::LValuePathEntry::ArrayIndex(asImpl().readUInt32()));
209210
}
210211
}
211-
return APValue::LValuePathSerializationHelper(path, elemTy);
212+
return APValue::LValuePathSerializationHelper(path, origTy);
212213
}
213214

214215
Qualifiers readQualifiers() {

clang/lib/AST/APValue.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ void APValue::LValuePathEntry::Profile(llvm::FoldingSetNodeID &ID) const {
156156

157157
APValue::LValuePathSerializationHelper::LValuePathSerializationHelper(
158158
ArrayRef<LValuePathEntry> Path, QualType ElemTy)
159-
: ElemTy((const void *)ElemTy.getTypePtrOrNull()), Path(Path) {}
159+
: Ty((const void *)ElemTy.getTypePtrOrNull()), Path(Path) {}
160160

161161
QualType APValue::LValuePathSerializationHelper::getType() {
162-
return QualType::getFromOpaquePtr(ElemTy);
162+
return QualType::getFromOpaquePtr(Ty);
163163
}
164164

165165
namespace {

0 commit comments

Comments
 (0)