[Modules] Fix an issue where the reconstructed redeclaration chain was incomplete, missing the definition from a module.

-Make sure that a deserialized external decl gets added to the TU scope.
-When associating an identifier with a set of decls, use the most recent local ones,
  if they exist, otherwise associating decls from modules (that came after a local one)
  will lead to an incomplete reconstructed re-declaration chain.

rdar://13712705

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180634 91177308-0d34-0410-b5e6-96231b3b80d8
7 files changed