[modules] Delay calling DeclMustBeEmitted until it's safe.

This patch implements the suggestion in D29753 that calling DeclMustBeEmitted in
the middle of deserialization should be avoided and that the actual check should
be deferred until it's safe to do so.

This patch fixes a crash when accessing the invalid redecl chains while trying
to evaluate the value of a const VarDecl that contains a function call.

Patch by Raphael Isemann (D30793)!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300110 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit 328c50cd2a53dbcac99fed88f823b8d73cde6bb0)

---

This is the PCM (modules) version of the PCH fix from
rdar://problem/30173654
3 files changed