[C++20] [Modules] Correct the redecl chain (#219926)
Close https://github.com/llvm/llvm-project/issues/219639
The root cause of the problem is the incorrect redecl chain.
A valid redecl chain should be a circle where each decl refers to the
previous one and the first decl refers to the most recent decl (latest
one). However, in the example, the redecl chain became to:
D2 -> D1 -> D1 ....
so that the range of `for (... : D->redecls())` never ends.
The real cause of the issue is we didn't merge correctly in the
ASTReader. Previous code assumes about the most recent decl while the
new code makes the behavior more clearly.