r314956 - PR33924: Merge block-scope anonymous declarations if there are multiple definitions of the enclosing function.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 4 17:47:24 PDT 2017
Author: rsmith
Date: Wed Oct 4 17:47:24 2017
New Revision: 314956
URL: http://llvm.org/viewvc/llvm-project?rev=314956&view=rev
Log:
PR33924: Merge block-scope anonymous declarations if there are multiple definitions of the enclosing function.
Modified:
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
Modified: cfe/trunk/lib/Serialization/ASTCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTCommon.cpp?rev=314956&r1=314955&r2=314956&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTCommon.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTCommon.cpp Wed Oct 4 17:47:24 2017
@@ -344,8 +344,8 @@ bool serialization::needsAnonymousDeclar
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);
}
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=314956&r1=314955&r2=314956&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Oct 4 17:47:24 2017
@@ -467,6 +467,7 @@ FunctionDecl *ASTDeclReader::TryRegister
// 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;
More information about the cfe-commits
mailing list