diff options
Diffstat (limited to 'lib/AST')
-rw-r--r-- | lib/AST/Decl.cpp | 7 | ||||
-rw-r--r-- | lib/AST/DeclBase.cpp | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 8521b9b44e..f29417ed13 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -164,6 +164,13 @@ FileScopeAsmDecl *FileScopeAsmDecl::Create(ASTContext &C, // 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; diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index f1ce3f3d0d..d9765ac4b4 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -514,6 +514,7 @@ DeclContext *DeclContext::getNextContext() { } void DeclContext::addDecl(ASTContext &Context, ScopedDecl *D, bool AllowLookup) { + assert(D->getLexicalDeclContext() == this && "Decl inserted into wrong lexical context"); Decls.push_back(D); if (AllowLookup) D->getDeclContext()->insert(Context, D); @@ -599,7 +600,6 @@ void DeclContext::insert(ASTContext &Context, ScopedDecl *D) { if (LookupPtr.getPointer()) insertImpl(D); - // If we are a transparent context, insert into our parent context, // too. This operation is recursive. if (isTransparentContext()) |