From: Richard Smith Date: Thu, 5 Oct 2017 00:47:24 +0000 (+0000) Subject: PR33924: Merge block-scope anonymous declarations if there are multiple definitions... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dbda370edbca549da400d99d15aea1e720e268ff;p=clang PR33924: Merge block-scope anonymous declarations if there are multiple definitions of the enclosing function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314956 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Serialization/ASTCommon.cpp b/lib/Serialization/ASTCommon.cpp index 9c6f03cd0b..7519dc239c 100644 --- a/lib/Serialization/ASTCommon.cpp +++ b/lib/Serialization/ASTCommon.cpp @@ -344,8 +344,8 @@ bool serialization::needsAnonymousDeclarationNumber(const NamedDecl *D) { return true; } - // Otherwise, we only care about anonymous class members. - if (D->getDeclName() || !isa(D->getLexicalDeclContext())) + // Otherwise, we only care about anonymous class members / block-scope decls. + if (D->getDeclName() || D->getLexicalDeclContext()->isFileContext()) return false; return isa(D) || isa(D); } diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 57f509ea6f..118417c930 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -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;