PR33924: merge local declarations that have linkage of some kind within
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 4 Jul 2018 02:25:38 +0000 (02:25 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 4 Jul 2018 02:25:38 +0000 (02:25 +0000)
commit600adef31bdb2dcc20f89a1633a55d27966e9de6
treec6cc4cc98ec051e5605d0a2293b996c36a2c1e86
parentf18adbb3cb327d119e6ba595a211afcc4a6ba196
PR33924: merge local declarations that have linkage of some kind within
merged function definitions; also merge functions with deduced return
types.

This seems like two independent fixes, but unfortunately they are hard
to separate because it's challenging to reliably test either one of them
without also testing the other.

A complication arises with deduced return type support: we need the type
of the function in order to know how to merge it, but we can't load the
actual type of the function because it might reference an entity
declared within the function (and we need to have already merged the
function to correctly merge that entity, which we would need to do to
determine if the function types match). So we instead compare the
declared function type when merging functions, and defer loading the
actual type of a function with a deduced type until we've finished
loading and merging the function.

This reverts r336175, reinstating r336021, with one change (for PR38015):
we look at the TypeSourceInfo of the first-so-far declaration of each
function when considering whether to merge two functions. This works
around a problem where the calling convention in the TypeSourceInfo for
subsequent redeclarations may not match if it was implicitly adjusted.

llvm-svn: 336240
clang/include/clang/Serialization/ASTReader.h
clang/lib/Serialization/ASTCommon.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/test/Modules/cxx-dtor.cpp
clang/test/Modules/friend-definition-2.cpp
clang/test/Modules/merge-deduced-return.cpp [new file with mode: 0644]
clang/test/Modules/merge-lambdas.cpp [new file with mode: 0644]
clang/test/Modules/merge-static-locals.cpp [new file with mode: 0644]
clang/test/Modules/pr27401.cpp