]> granicus.if.org Git - clang/commitdiff
[modules] Don't try to add lookup results to non-lookup contexts.
authorVassil Vassilev <v.g.vassilev@gmail.com>
Wed, 6 Apr 2016 20:56:03 +0000 (20:56 +0000)
committerVassil Vassilev <v.g.vassilev@gmail.com>
Wed, 6 Apr 2016 20:56:03 +0000 (20:56 +0000)
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

lib/AST/DeclBase.cpp
lib/Serialization/ASTWriter.cpp

index 5ec05a6604b89a6e0ddbae90334bd69e42b624a1..2722b82ef12de0da885a3f4d7c0f8e9c842668d2 100644 (file)
@@ -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))
index 4dec7279781e6f54a314bbacd3c22f25f1396102..ef7d8ee2ad2d6702f0b8da831862b442b909bcca 100644 (file)
@@ -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<TranslationUnitDecl>(DC))
     return;