Skip to content

Commit 2021962

Browse files
committed
Fix the serialization for invalid constraints
1 parent 3127761 commit 2021962

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

clang/lib/Serialization/ASTReaderDecl.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2663,7 +2663,11 @@ void ASTDeclReader::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
26632663

26642664
D->setDeclaredWithTypename(Record.readInt());
26652665

2666-
if (D->hasTypeConstraint()) {
2666+
bool TypeConstraintInitialized = false;
2667+
if (D->hasTypeConstraint())
2668+
TypeConstraintInitialized = Record.readBool();
2669+
2670+
if (D->hasTypeConstraint() && TypeConstraintInitialized) {
26672671
ConceptReference *CR = nullptr;
26682672
if (Record.readBool())
26692673
CR = Record.readConceptReference();

clang/lib/Serialization/ASTWriterDecl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1951,6 +1951,8 @@ void ASTDeclWriter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
19511951
Record.push_back(D->wasDeclaredWithTypename());
19521952

19531953
const TypeConstraint *TC = D->getTypeConstraint();
1954+
if (D->hasTypeConstraint())
1955+
Record.push_back(/*TypeConstraintInitialized=*/TC != nullptr);
19541956
if (TC) {
19551957
auto *CR = TC->getConceptReference();
19561958
Record.push_back(CR != nullptr);
@@ -1968,7 +1970,7 @@ void ASTDeclWriter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
19681970
if (OwnsDefaultArg)
19691971
Record.AddTemplateArgumentLoc(D->getDefaultArgument());
19701972

1971-
if (!TC && !OwnsDefaultArg &&
1973+
if (!D->hasTypeConstraint() && !OwnsDefaultArg &&
19721974
D->getDeclContext() == D->getLexicalDeclContext() &&
19731975
!D->isInvalidDecl() && !D->hasAttrs() &&
19741976
!D->isTopLevelDeclInObjCContainer() && !D->isImplicit() &&

0 commit comments

Comments
 (0)