From c6848efaac6836930ac9558060628cb094db3ff9 Mon Sep 17 00:00:00 2001 From: Axel Naumann Date: Thu, 4 Oct 2012 07:34:43 +0000 Subject: [PATCH] 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. llvm-svn: 165215 --- clang/lib/Serialization/ASTReaderDecl.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index d9243f6..762ad01 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/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); } } -- 2.7.4