|
|
@ -1198,13 +1198,13 @@ void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) {
|
|
|
|
D->LocStart = ReadSourceLocation(Record, Idx);
|
|
|
|
D->LocStart = ReadSourceLocation(Record, Idx);
|
|
|
|
D->RBraceLoc = ReadSourceLocation(Record, Idx);
|
|
|
|
D->RBraceLoc = ReadSourceLocation(Record, Idx);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Defer loading the anonymous namespace until we've finished merging
|
|
|
|
|
|
|
|
// this namespace; loading it might load a later declaration of the
|
|
|
|
|
|
|
|
// same namespace, and we have an invariant that older declarations
|
|
|
|
|
|
|
|
// get merged before newer ones try to merge.
|
|
|
|
|
|
|
|
GlobalDeclID AnonNamespace = 0;
|
|
|
|
if (Redecl.getFirstID() == ThisDeclID) {
|
|
|
|
if (Redecl.getFirstID() == ThisDeclID) {
|
|
|
|
// Each module has its own anonymous namespace, which is disjoint from
|
|
|
|
AnonNamespace = ReadDeclID(Record, Idx);
|
|
|
|
// any other module's anonymous namespaces, so don't attach the anonymous
|
|
|
|
|
|
|
|
// namespace at all.
|
|
|
|
|
|
|
|
NamespaceDecl *Anon = ReadDeclAs<NamespaceDecl>(Record, Idx);
|
|
|
|
|
|
|
|
if (F.Kind != MK_ImplicitModule && F.Kind != MK_ExplicitModule)
|
|
|
|
|
|
|
|
D->setAnonymousNamespace(Anon);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Link this namespace back to the first declaration, which has already
|
|
|
|
// Link this namespace back to the first declaration, which has already
|
|
|
|
// been deserialized.
|
|
|
|
// been deserialized.
|
|
|
@ -1212,6 +1212,15 @@ void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mergeRedeclarable(D, Redecl);
|
|
|
|
mergeRedeclarable(D, Redecl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (AnonNamespace) {
|
|
|
|
|
|
|
|
// Each module has its own anonymous namespace, which is disjoint from
|
|
|
|
|
|
|
|
// any other module's anonymous namespaces, so don't attach the anonymous
|
|
|
|
|
|
|
|
// namespace at all.
|
|
|
|
|
|
|
|
NamespaceDecl *Anon = cast<NamespaceDecl>(Reader.GetDecl(AnonNamespace));
|
|
|
|
|
|
|
|
if (F.Kind != MK_ImplicitModule && F.Kind != MK_ExplicitModule)
|
|
|
|
|
|
|
|
D->setAnonymousNamespace(Anon);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ASTDeclReader::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
|
|
|
|
void ASTDeclReader::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
|
|
|
@ -2196,6 +2205,8 @@ void ASTDeclReader::mergeRedeclarable(Redeclarable<T> *DBase, T *Existing,
|
|
|
|
D->RedeclLink = Redeclarable<T>::PreviousDeclLink(ExistingCanon);
|
|
|
|
D->RedeclLink = Redeclarable<T>::PreviousDeclLink(ExistingCanon);
|
|
|
|
|
|
|
|
|
|
|
|
// When we merge a namespace, update its pointer to the first namespace.
|
|
|
|
// When we merge a namespace, update its pointer to the first namespace.
|
|
|
|
|
|
|
|
// We cannot have loaded any redeclarations of this declaration yet, so
|
|
|
|
|
|
|
|
// there's nothing else that needs to be updated.
|
|
|
|
if (auto *Namespace = dyn_cast<NamespaceDecl>(D))
|
|
|
|
if (auto *Namespace = dyn_cast<NamespaceDecl>(D))
|
|
|
|
Namespace->AnonOrFirstNamespaceAndInline.setPointer(
|
|
|
|
Namespace->AnonOrFirstNamespaceAndInline.setPointer(
|
|
|
|
assert_cast<NamespaceDecl*>(ExistingCanon));
|
|
|
|
assert_cast<NamespaceDecl*>(ExistingCanon));
|
|
|
@ -2206,9 +2217,7 @@ void ASTDeclReader::mergeRedeclarable(Redeclarable<T> *DBase, T *Existing,
|
|
|
|
DTemplate, assert_cast<RedeclarableTemplateDecl*>(ExistingCanon),
|
|
|
|
DTemplate, assert_cast<RedeclarableTemplateDecl*>(ExistingCanon),
|
|
|
|
TemplatePatternID);
|
|
|
|
TemplatePatternID);
|
|
|
|
|
|
|
|
|
|
|
|
// If this declaration was the canonical declaration, make a note of
|
|
|
|
// If this declaration was the canonical declaration, make a note of that.
|
|
|
|
// that. We accept the linear algorithm here because the number of
|
|
|
|
|
|
|
|
// unique canonical declarations of an entity should always be tiny.
|
|
|
|
|
|
|
|
if (DCanon == D) {
|
|
|
|
if (DCanon == D) {
|
|
|
|
Reader.MergedDecls[ExistingCanon].push_back(Redecl.getFirstID());
|
|
|
|
Reader.MergedDecls[ExistingCanon].push_back(Redecl.getFirstID());
|
|
|
|
if (Reader.PendingDeclChainsKnown.insert(ExistingCanon).second)
|
|
|
|
if (Reader.PendingDeclChainsKnown.insert(ExistingCanon).second)
|
|
|
|