When reading in the DeclCtx during deserialization, register the DeclCtx of the
ScopedDecl with the backpatcher, and *not* a local variable on the stack. The
value of DeclCtx gets filled in *later* by the backpatcher.
This fixes: http://llvm.org/bugs/show_bug.cgi?id=2308
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50976 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclSerialization.cpp b/lib/AST/DeclSerialization.cpp
index cbae831..291649b 100644
--- a/lib/AST/DeclSerialization.cpp
+++ b/lib/AST/DeclSerialization.cpp
@@ -116,9 +116,10 @@
void ScopedDecl::ReadInRec(Deserializer& D, ASTContext& C) {
NamedDecl::ReadInRec(D, C);
D.ReadPtr(Next); // From ScopedDecl.
- Decl *TmpD;
- D.ReadPtr(TmpD); // From ScopedDecl.
- DeclCtx = cast_or_null<DeclContext>(TmpD);
+
+ DeclCtx = 0; // Allow back-patching. Observe that we register
+ D.ReadPtr(DeclCtx); // the variable of the *object* for back-patching.
+ // It's actual value will get filled in later.
}
//===------------------------------------------------------------===//