From: Vassil Vassilev Date: Wed, 6 Apr 2016 20:56:03 +0000 (+0000) Subject: [modules] Don't try to add lookup results to non-lookup contexts. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8bb4ef4de38407713d2f906aa82fdb8913d2c0e4;p=clang [modules] Don't try to add lookup results to non-lookup contexts. Fixes https://llvm.org/bugs/show_bug.cgi?id=27186 Patch reviewed by Richard Smith. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@265597 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 5ec05a6604..2722b82ef1 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -1559,9 +1559,12 @@ void DeclContext::makeDeclVisibleInContextWithFlags(NamedDecl *D, bool Internal, bool Recoverable) { assert(this == getPrimaryContext() && "expected a primary DC"); - // Skip declarations within functions. - if (isFunctionOrMethod()) + if (!isLookupContext()) { + if (isTransparentContext()) + getParent()->getPrimaryContext() + ->makeDeclVisibleInContextWithFlags(D, Internal, Recoverable); return; + } // Skip declarations which should be invisible to name lookup. if (shouldBeHidden(D)) diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 4dec727978..ef7d8ee2ad 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -5736,6 +5736,9 @@ static bool isImportedDeclContext(ASTReader *Chain, const Decl *D) { } void ASTWriter::AddedVisibleDecl(const DeclContext *DC, const Decl *D) { + assert(DC->isLookupContext() && + "Should not add lookup results to non-lookup contexts!"); + // TU is handled elsewhere. if (isa(DC)) return;