Make sure that ScopedDecls passed to DeclContext::addDecl are added into their lexical context
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61998 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 8521b9b..f29417e 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -164,6 +164,13 @@
// ScopedDecl Implementation
//===----------------------------------------------------------------------===//
+void ScopedDecl::setDeclContext(DeclContext *DC) {
+ if (isOutOfSemaDC())
+ delete getMultipleDC();
+
+ DeclCtx = reinterpret_cast<uintptr_t>(DC);
+}
+
void ScopedDecl::setLexicalDeclContext(DeclContext *DC) {
if (DC == getLexicalDeclContext())
return;