Skip to content

Commit 39986f0

Browse files
committed
[NFCI] [Serialization] Use demoteThisDefinitionToDeclaration instead of setCompleteDefinition(false) for CXXRecordDecl
When we merge the definition for CXXRecordDecl, we would use setCompleteDefinition(false) to mark the merged definition. But this was not the correct/good interface. We can't know that the merged definition was a definition then. And actually, we provided an interface for this: demoteThisDefinitionToDeclaration. So this patch tries to use the correct API. This was found in the downstream developing. This is not strictly NFC but it is intended to be NFC for every end users.
1 parent e5f196e commit 39986f0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

clang/lib/Serialization/ASTReaderDecl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,7 @@ void ASTDeclMerger::MergeDefinitionData(
20642064
Reader.MergedDeclContexts.insert(std::make_pair(MergeDD.Definition,
20652065
DD.Definition));
20662066
Reader.PendingDefinitions.erase(MergeDD.Definition);
2067-
MergeDD.Definition->setCompleteDefinition(false);
2067+
MergeDD.Definition->demoteThisDefinitionToDeclaration();
20682068
Reader.mergeDefinitionVisibility(DD.Definition, MergeDD.Definition);
20692069
assert(!Reader.Lookups.contains(MergeDD.Definition) &&
20702070
"already loaded pending lookups for merged definition");
@@ -2175,6 +2175,9 @@ void ASTDeclReader::ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update,
21752175
D->DefinitionData = Canon->DefinitionData;
21762176
ReadCXXDefinitionData(*DD, D, LambdaContext, IndexInLambdaContext);
21772177

2178+
// Mark this declaration as being a definition.
2179+
D->setCompleteDefinition(true);
2180+
21782181
// We might already have a different definition for this record. This can
21792182
// happen either because we're reading an update record, or because we've
21802183
// already done some merging. Either way, just merge into it.
@@ -2183,9 +2186,6 @@ void ASTDeclReader::ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update,
21832186
return;
21842187
}
21852188

2186-
// Mark this declaration as being a definition.
2187-
D->setCompleteDefinition(true);
2188-
21892189
// If this is not the first declaration or is an update record, we can have
21902190
// other redeclarations already. Make a note that we need to propagate the
21912191
// DefinitionData pointer onto them.

0 commit comments

Comments
 (0)