From dbda370edbca549da400d99d15aea1e720e268ff Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 5 Oct 2017 00:47:24 +0000 Subject: [PATCH] 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 --- lib/Serialization/ASTCommon.cpp | 4 ++-- lib/Serialization/ASTReaderDecl.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) 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; -- 2.40.0