From: Axel Naumann Date: Thu, 4 Oct 2012 07:34:43 +0000 (+0000) Subject: Fix r165005: The lexical DeclContext is not the right place to make a decision about... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=351dbbea9820c79fcc38ed9fe93613ccb839a17f;p=clang Fix r165005: The lexical DeclContext is not the right place to make a decision about whether we need to call tryAddTopLevelDecl or not. That call should be made when the DeclContext's redeclaration context is the translation unit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165215 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index d9243f62e5..762ad01b51 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -1781,11 +1781,13 @@ ASTDeclReader::FindExistingResult::~FindExistingResult() { if (!AddResult || Existing) return; - DeclContext *DC = New->getLexicalDeclContext(); - if (DC->isTranslationUnit() && Reader.SemaObj) { + if (New->getDeclContext()->getRedeclContext()->isTranslationUnit() + && Reader.SemaObj) { Reader.SemaObj->IdResolver.tryAddTopLevelDecl(New, New->getDeclName()); - } else if (DC->isNamespace()) { - DC->addDecl(New); + } else { + DeclContext *DC = New->getLexicalDeclContext(); + if (DC->isNamespace()) + DC->addDecl(New); } }