Ensure that the identifier chains have the most recent declaration after module deser...
authorDouglas Gregor <dgregor@apple.com>
Mon, 18 Feb 2013 15:53:43 +0000 (15:53 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 18 Feb 2013 15:53:43 +0000 (15:53 +0000)
commit6168bd2323cdf2ff1dc4174c6fc4cd6a479f001b
treea03e28f83a781867f322b1d080f62c0ebfd7f4c2
parent1ce13f553ee36acca05d356f4bcd24d36c5df52f
Ensure that the identifier chains have the most recent declaration after module deserialization.

This commit introduces a set of related changes to ensure that the
declaration that shows up in the identifier chain after deserializing
declarations with a given identifier is, in fact, the most recent
declaration. The primary change involves waiting until after we
deserialize and wire up redeclaration chains before updating the
identifier chains. There is a minor optimization in here to avoid
recursively deserializing names as part of looking to see whether
top-level declarations for a given name exist.

A related change that became suddenly more urgent is to property
record a merged declaration when an entity first declared in the
current translation unit is later deserialized from a module (that had
not been loaded at the time of the original declaration). Since we key
off the canonical declaration (which is parsed, not from an AST file)
for emitted redeclarations, we simply record this as a merged
declaration during AST writing and let the readers merge them.

Re-fixes <rdar://problem/13189985>, presumably for good this time.

llvm-svn: 175447
clang/include/clang/Serialization/ASTReader.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/Modules/Inputs/redecl-merge-left.h
clang/test/Modules/Inputs/redecl-merge-right.h
clang/test/Modules/Inputs/redecl-merge-top.h
clang/test/Modules/redecl-merge.m