PR33924: Merge block-scope anonymous declarations if there are multiple definitions of the enclosing function.

llvm-svn: 314956
This commit is contained in:
Richard Smith 2017-10-05 00:47:24 +00:00
parent 3ea492ad74
commit b80e7533bf
2 changed files with 3 additions and 2 deletions

View File

@ -344,8 +344,8 @@ bool serialization::needsAnonymousDeclarationNumber(const NamedDecl *D) {
return true;
}
// Otherwise, we only care about anonymous class members.
if (D->getDeclName() || !isa<CXXRecordDecl>(D->getLexicalDeclContext()))
// Otherwise, we only care about anonymous class members / block-scope decls.
if (D->getDeclName() || D->getLexicalDeclContext()->isFileContext())
return false;
return isa<TagDecl>(D) || isa<FieldDecl>(D);
}

View File

@ -467,6 +467,7 @@ FunctionDecl *ASTDeclReader::TryRegisterAsFunctionDefinition(FunctionDecl *D) {
// declaration.
if (Definition != D) {
// Already have a different definition, merge this one into it.
Reader.MergedDeclContexts.insert(std::make_pair(D, Definition));
Reader.mergeDefinitionVisibility(Definition, D);
}
return Definition;