In case where we have removed all declarations for a given declaration name
entry we should remove the whole StoredDeclsMap entry.
This patch improves consistency in the lookup tables and helps cling/clang-repl
error recovery.
Differential revision: https://reviews.llvm.org/D119675
if (Map) {
StoredDeclsMap::iterator Pos = Map->find(ND->getDeclName());
assert(Pos != Map->end() && "no lookup entry for decl");
- Pos->second.remove(ND);
+ StoredDeclsList &List = Pos->second;
+ List.remove(ND);
+ // Clean up the entry if there are no more decls.
+ if (List.isNull())
+ Map->erase(Pos);
}
} while (DC->isTransparentContext() && (DC = DC->getParent()));
}
// This asserts in the old implementation.
DC->removeDecl(A0);
EXPECT_FALSE(DC->containsDecl(A0));
+
+ // Make sure we do not leave a StoredDeclsList with no entries.
+ DC->removeDecl(A1);
+ ASSERT_EQ(Map->find(A1->getDeclName()), Map->end());
}
struct ImportFunctionTemplateSpecializations