Browse Source

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
Richard Smith 7 years ago
parent
commit
dbda370edb
2 changed files with 3 additions and 2 deletions
  1. 2 2
      lib/Serialization/ASTCommon.cpp
  2. 1 0
      lib/Serialization/ASTReaderDecl.cpp

+ 2 - 2
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<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);
 }

+ 1 - 0
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;