Lines Matching defs:ND

59 /// If \p ND is a template specialization, returns the described template.
60 /// Otherwise, returns \p ND.
61 const NamedDecl &getTemplateOrThis(const NamedDecl &ND) {
62 if (auto *T = ND.getDescribedTemplate())
64 return ND;
71 bool isPrivateProtoDecl(const NamedDecl &ND) {
72 const auto &SM = ND.getASTContext().getSourceManager();
73 if (!isProtoFile(nameLocation(ND, SM), SM))
76 // ND without identifier can be operators.
77 if (ND.getIdentifier() == nullptr)
79 auto Name = ND.getIdentifier()->getName();
105 if (ND.getDeclContext()->isNamespace()) {
124 if (llvm::isa<EnumConstantDecl>(&ND)) {
125 auto *DC = llvm::cast<EnumDecl>(ND.getDeclContext());
180 // Checks whether \p ND is a good candidate to be the *canonical* declaration of
185 bool isPreferredDeclaration(const NamedDecl &ND, index::SymbolRoleSet Roles) {
186 const auto &SM = ND.getASTContext().getSourceManager();
187 if (isa<TagDecl>(ND))
189 !isInsideMainFile(ND.getLocation(), SM);
190 if (const auto *ID = dyn_cast<ObjCInterfaceDecl>(&ND))
192 if (const auto *PD = dyn_cast<ObjCProtocolDecl>(&ND))
218 // Check if there is an exact spelling of \p ND at \p Loc.
219 bool isSpelled(SourceLocation Loc, const NamedDecl &ND) {
220 auto Name = ND.getDeclName();
228 const auto &AST = ND.getASTContext();
235 if (const auto *MD = dyn_cast<ObjCMethodDecl>(&ND))
506 bool SymbolCollector::shouldCollectSymbol(const NamedDecl &ND,
511 if (ND.getDeclName().isEmpty())
519 if (!IsMainFileOnly && ND.isInAnonymousNamespace())
523 if (index::isFunctionLocalSymbol(&ND))
524 return isa<RecordDecl>(ND) ||
525 (ND.isCXXInstanceMember() && ND.isFunctionOrFunctionTemplate());
531 const auto *DeclCtx = ND.getDeclContext();
551 if (isPrivateProtoDecl(ND))
556 (hasReservedName(ND) || hasReservedScope(*ND.getDeclContext())) &&
557 ASTCtx.getSourceManager().isInSystemHeader(ND.getLocation()) &&
559 .getFilename(ND.getLocation())
570 const auto *ND = dyn_cast<NamedDecl>(Enclosing);
571 if (ND && shouldCollectSymbol(*ND, ND->getASTContext(), Opts, true)) {
623 const NamedDecl *ND = dyn_cast<NamedDecl>(D);
624 if (!ND)
627 auto ID = getSymbolIDCached(ND);
639 // ND is the canonical (i.e. first) declaration. If it's in the main file
643 SM.isWrittenInMainFile(SM.getExpansionLoc(ND->getBeginLoc())) &&
648 !shouldCollectSymbol(*ND, *ASTCtx, Opts, IsMainFileOnly))
655 processRelations(*ND, ID, Relations);
664 ND->isExternallyVisible()) &&
665 !isa<NamespaceDecl>(ND)) {
669 addRef(ID, SymbolRef{FileLoc, FID, Roles, index::getSymbolInfo(ND).Kind,
671 isSpelled(FileLoc, *ND)});
696 BasicSymbol = addDeclaration(*ND, std::move(ID), IsMainFileOnly);
847 const NamedDecl &ND, const SymbolID &ID,
1040 const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND, SymbolID ID,
1042 auto &Ctx = ND.getASTContext();
1047 std::string QName = printQualifiedName(ND);
1051 std::string TemplateSpecializationArgs = printTemplateSpecializationArgs(ND);
1055 if (!IsMainFileOnly && isIndexedForCodeCompletion(ND, Ctx))
1057 if (isImplementationDetail(&ND))
1061 S.SymInfo = index::getSymbolInfo(&ND);
1062 auto Loc = nameLocation(ND, SM);
1071 if (ND.getAvailability() == AR_Deprecated)
1078 CodeCompletionResult SymbolCompletion(&getTemplateOrThis(ND), 0);
1122 setIncludeLocation(S, ND.getLocation(), include_cleaner::Symbol{ND});
1128 void SymbolCollector::addDefinition(const NamedDecl &ND, const Symbol &DeclSym,
1132 const auto &SM = ND.getASTContext().getSourceManager();
1133 auto Loc = nameLocation(ND, SM);
1148 (llvm::isa<FunctionDecl>(ND) || llvm::isa<CXXMethodDecl>(ND))) {
1149 CodeCompletionResult SymbolCompletion(&getTemplateOrThis(ND), 0);
1154 DocComment = getDocComment(ND.getASTContext(), SymbolCompletion,