diff --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp b/clang-tools-extra/clangd/index/SymbolCollector.cpp --- a/clang-tools-extra/clangd/index/SymbolCollector.cpp +++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp @@ -340,8 +340,9 @@ // TU, because in practice they are definitions. BasicSymbol = addDeclaration(*OriginalDecl, std::move(*ID), IsMainFileOnly); - if (Roles & static_cast(index::SymbolRole::Definition)) - addDefinition(*OriginalDecl, *BasicSymbol); + if (BasicSymbol != nullptr) + if (Roles & static_cast(index::SymbolRole::Definition)) + addDefinition(*OriginalDecl, *BasicSymbol); return true; } @@ -434,8 +435,8 @@ S.SymInfo = index::getSymbolInfoForMacro(*MI); S.Origin = Opts.Origin; std::string FileURI; - // FIXME: use the result to filter out symbols. - shouldIndexFile(SM.getFileID(Loc)); + if (!shouldIndexFile(SM.getFileID(Loc))) + return false; if (auto DeclLoc = getTokenLocation(DefLoc, SM, Opts, PP->getLangOpts(), FileURI)) S.CanonicalDeclaration = *DeclLoc; @@ -561,8 +562,8 @@ const std::pair &LocAndRole, bool Spelled = false) { auto FileID = SM.getFileID(LocAndRole.first); - // FIXME: use the result to filter out references. - shouldIndexFile(FileID); + if (!shouldIndexFile(FileID)) + return; if (auto FileURI = GetURI(FileID)) { auto Range = getTokenRange(LocAndRole.first, SM, ASTCtx->getLangOpts()); @@ -639,8 +640,8 @@ std::string FileURI; auto Loc = nameLocation(ND, SM); assert(Loc.isValid() && "Invalid source location for NamedDecl"); - // FIXME: use the result to filter out symbols. - shouldIndexFile(SM.getFileID(Loc)); + if (!shouldIndexFile(SM.getFileID(Loc))) + return nullptr; if (auto DeclLoc = getTokenLocation(Loc, SM, Opts, ASTCtx->getLangOpts(), FileURI)) S.CanonicalDeclaration = *DeclLoc; @@ -699,8 +700,8 @@ std::string FileURI; const auto &SM = ND.getASTContext().getSourceManager(); auto Loc = nameLocation(ND, SM); - // FIXME: use the result to filter out symbols. - shouldIndexFile(SM.getFileID(Loc)); + if (!shouldIndexFile(SM.getFileID(Loc))) + return; if (auto DefLoc = getTokenLocation(Loc, SM, Opts, ASTCtx->getLangOpts(), FileURI)) S.Definition = *DefLoc;