Namespace: improve indexer and don't trace bases in $ccls/member

This commit is contained in:
Fangrui Song 2018-10-09 22:29:51 -07:00
parent 3de62168c8
commit 7b19c87485
2 changed files with 20 additions and 9 deletions

View File

@ -719,8 +719,17 @@ public:
// spell, extent, comments use OrigD while most others use adjusted |D|. // spell, extent, comments use OrigD while most others use adjusted |D|.
const Decl *OrigD = ASTNode.OrigD; const Decl *OrigD = ASTNode.OrigD;
const DeclContext *SemDC = OrigD->getDeclContext(); const DeclContext *SemDC = OrigD->getDeclContext()->getRedeclContext();
const DeclContext *LexDC = ASTNode.ContainerDC; const DeclContext *LexDC = ASTNode.ContainerDC->getRedeclContext();
{
const NamespaceDecl *ND;
while ((ND = dyn_cast<NamespaceDecl>(cast<Decl>(SemDC))) &&
ND->isAnonymousNamespace())
SemDC = ND->getDeclContext()->getRedeclContext();
while ((ND = dyn_cast<NamespaceDecl>(cast<Decl>(LexDC))) &&
ND->isAnonymousNamespace())
LexDC = ND->getDeclContext()->getRedeclContext();
}
Role role = static_cast<Role>(Roles); Role role = static_cast<Role>(Roles);
db->language = LanguageId((int)db->language | (int)GetDeclLanguage(D)); db->language = LanguageId((int)db->language | (int)GetDeclLanguage(D));

View File

@ -133,14 +133,16 @@ bool Expand(MessageHandler *m, Out_CclsMember::Entry *entry,
type = stack.back(); type = stack.back();
stack.pop_back(); stack.pop_back();
const auto *def = type->AnyDef(); const auto *def = type->AnyDef();
if (!def) continue; if (!def)
for (Usr usr : def->bases) { continue;
auto &type1 = m->db->Type(usr); if (def->kind != lsSymbolKind::Namespace)
if (type1.def.size()) { for (Usr usr : def->bases) {
seen.insert(type1.usr); auto &type1 = m->db->Type(usr);
stack.push_back(&type1); if (type1.def.size()) {
seen.insert(type1.usr);
stack.push_back(&type1);
}
} }
}
if (def->alias_of) { if (def->alias_of) {
const QueryType::Def *def1 = m->db->Type(def->alias_of).AnyDef(); const QueryType::Def *def1 = m->db->Type(def->alias_of).AnyDef();
Out_CclsMember::Entry entry1; Out_CclsMember::Entry entry1;