Skip to content

Commit 38d144e

Browse files
Do not serialize PlaceholderTypeConstraintInitialized if
hasPlaceholderTypeConstraint is false
1 parent 869eae8 commit 38d144e

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

clang/lib/Serialization/ASTReaderDecl.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2703,8 +2703,10 @@ void ASTDeclReader::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
27032703
// TemplateParmPosition.
27042704
D->setDepth(Record.readInt());
27052705
D->setPosition(Record.readInt());
2706-
if (Record.readBool()) // PlaceholderTypeConstraintInitialized
2707-
D->setPlaceholderTypeConstraint(Record.readExpr());
2706+
if (D->hasPlaceholderTypeConstraint()) {
2707+
if (Record.readBool()) // PlaceholderTypeConstraintInitialized
2708+
D->setPlaceholderTypeConstraint(Record.readExpr());
2709+
}
27082710
if (D->isExpandedParameterPack()) {
27092711
auto TypesAndInfos =
27102712
D->getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();

clang/lib/Serialization/ASTWriterDecl.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,11 +1993,14 @@ void ASTDeclWriter::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
19931993
// TemplateParmPosition.
19941994
Record.push_back(D->getDepth());
19951995
Record.push_back(D->getPosition());
1996-
Expr *TypeConstraint = D->getPlaceholderTypeConstraint();
1997-
Record.push_back(/*PlaceholderTypeConstraintInitialized=*/TypeConstraint !=
1998-
nullptr);
1999-
if (TypeConstraint)
2000-
Record.AddStmt(TypeConstraint);
1996+
1997+
if (D->hasPlaceholderTypeConstraint()) {
1998+
Expr *TypeConstraint = D->getPlaceholderTypeConstraint();
1999+
Record.push_back(/*PlaceholderTypeConstraintInitialized=*/TypeConstraint !=
2000+
nullptr);
2001+
if (TypeConstraint)
2002+
Record.AddStmt(TypeConstraint);
2003+
}
20012004

20022005
if (D->isExpandedParameterPack()) {
20032006
for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {

0 commit comments

Comments
 (0)