Lines Matching full:d

21 #define TRY_DECL(D,CALL_EXPR)                                                  \
23 if (!IndexCtx.shouldIndex(D)) return true; \
45 bool VisitDecl(const Decl *D) {
79 static bool hasUserDefined(const ObjCMethodDecl *D,
81 const ObjCMethodDecl *MD = Container->getMethod(D->getSelector(),
82 D->isInstanceMethod());
88 void handleDeclarator(const DeclaratorDecl *D,
91 if (!Parent) Parent = D;
93 IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), Parent,
96 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
104 if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
116 } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
120 IndexDefaultParmeterArgument(PI, D);
127 if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
130 IndexDefaultParmeterArgument(PV, D);
135 if (auto *C = D->getTrailingRequiresClause())
139 bool handleObjCMethod(const ObjCMethodDecl *D,
144 D->getOverriddenMethods(Overriden);
155 SourceLocation MethodLoc = D->getSelectorStartLoc();
157 MethodLoc = D->getLocation();
163 bool isGetter = !D->param_size();
170 if (D->isImplicit()) {
177 IndexCtx.handleReference(D, AttrLoc, cast<NamedDecl>(D->getDeclContext()),
178 D->getDeclContext(), 0);
181 TRY_DECL(D, IndexCtx.handleDecl(D, MethodLoc, Roles, Relations));
182 IndexCtx.indexTypeSourceInfo(D->getReturnTypeSourceInfo(), D);
183 bool hasIBActionAndFirst = D->hasAttr<IBActionAttr>();
184 for (const auto *I : D->parameters()) {
185 handleDeclarator(I, D, /*isIBType=*/hasIBActionAndFirst);
189 if (D->isThisDeclarationADefinition()) {
190 const Stmt *Body = D->getBody();
192 IndexCtx.indexBody(Body, D, D);
198 /// Gather the declarations which the given declaration \D overrides in a
205 gatherTemplatePseudoOverrides(const NamedDecl *D,
210 dyn_cast<ClassTemplateSpecializationDecl>(D->getLexicalDeclContext());
218 bool TypeOverride = isa<TypeDecl>(D);
219 for (const NamedDecl *ND : Pattern->lookup(D->getDeclName())) {
226 if (ND->getKind() != D->getKind())
231 const auto *DFD = cast<FunctionDecl>(D);
243 bool VisitFunctionDecl(const FunctionDecl *D) {
246 if (auto *CXXMD = dyn_cast<CXXMethodDecl>(D)) {
253 gatherTemplatePseudoOverrides(D, Relations);
254 if (const auto *Base = D->getPrimaryTemplate())
259 TRY_DECL(D, IndexCtx.handleDecl(D, Roles, Relations));
260 handleDeclarator(D);
262 if (const CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D)) {
270 IndexCtx.indexTypeSourceInfo(Init->getTypeSourceInfo(), D);
272 IndexCtx.handleReference(Member, Init->getMemberLocation(), D, D,
274 IndexCtx.indexBody(Init->getInit(), D, D);
277 } else if (const CXXDestructorDecl *Dtor = dyn_cast<CXXDestructorDecl>(D)) {
284 } else if (const auto *Guide = dyn_cast<CXXDeductionGuideDecl>(D)) {
291 D->getTemplateSpecializationArgsAsWritten()) {
293 handleTemplateArgumentLoc(Arg, D, D->getLexicalDeclContext());
296 if (D->isThisDeclarationADefinition()) {
297 const Stmt *Body = D->getBody();
299 IndexCtx.indexBody(Body, D, D);
305 bool VisitVarDecl(const VarDecl *D) {
307 gatherTemplatePseudoOverrides(D, Relations);
308 TRY_DECL(D, IndexCtx.handleDecl(D, SymbolRoleSet(), Relations));
309 handleDeclarator(D);
310 IndexCtx.indexBody(D->getInit(), D);
314 bool VisitDecompositionDecl(const DecompositionDecl *D) {
315 for (const auto *Binding : D->bindings())
317 return Base::VisitDecompositionDecl(D);
320 bool VisitFieldDecl(const FieldDecl *D) {
322 gatherTemplatePseudoOverrides(D, Relations);
323 TRY_DECL(D, IndexCtx.handleDecl(D, SymbolRoleSet(), Relations));
324 handleDeclarator(D);
325 if (D->isBitField())
326 IndexCtx.indexBody(D->getBitWidth(), D);
327 else if (D->hasInClassInitializer())
328 IndexCtx.indexBody(D->getInClassInitializer(), D);
332 bool VisitObjCIvarDecl(const ObjCIvarDecl *D) {
333 if (D->getSynthesize()) {
337 TRY_DECL(D, IndexCtx.handleDecl(D));
338 handleDeclarator(D);
342 bool VisitMSPropertyDecl(const MSPropertyDecl *D) {
343 TRY_DECL(D, IndexCtx.handleDecl(D));
344 handleDeclarator(D);
348 bool VisitEnumConstantDecl(const EnumConstantDecl *D) {
349 TRY_DECL(D, IndexCtx.handleDecl(D));
350 IndexCtx.indexBody(D->getInitExpr(), D);
354 bool VisitTypedefNameDecl(const TypedefNameDecl *D) {
355 if (!D->isTransparentTag()) {
357 gatherTemplatePseudoOverrides(D, Relations);
358 TRY_DECL(D, IndexCtx.handleDecl(D, SymbolRoleSet(), Relations));
359 IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), D);
364 bool VisitTagDecl(const TagDecl *D) {
366 if (D->isFreeStanding()) {
367 if (D->isThisDeclarationADefinition()) {
369 gatherTemplatePseudoOverrides(D, Relations);
370 IndexCtx.indexTagDecl(D, Relations);
373 gatherTemplatePseudoOverrides(D, Relations);
374 return IndexCtx.handleDecl(D, D->getLocation(), SymbolRoleSet(),
375 Relations, D->getLexicalDeclContext());
407 bool VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D) {
408 if (D->isThisDeclarationADefinition()) {
409 TRY_DECL(D, IndexCtx.handleDecl(D));
410 SourceLocation SuperLoc = D->getSuperClassLoc();
411 if (auto *SuperD = D->getSuperClass()) {
413 if (auto *TInfo = D->getSuperClassTInfo()) {
417 TRY_TO(IndexCtx.handleReference(TD, SuperLoc, D, D,
425 TRY_TO(IndexCtx.handleReference(SuperD, SuperLoc, D, D, superRoles,
426 SymbolRelation{(unsigned)SymbolRole::RelationBaseOf, D}));
428 TRY_TO(handleReferencedProtocols(D->getReferencedProtocols(), D,
430 TRY_TO(IndexCtx.indexDeclContext(D));
432 return IndexCtx.handleReference(D, D->getLocation(), nullptr,
433 D->getDeclContext(), SymbolRoleSet());
438 bool VisitObjCProtocolDecl(const ObjCProtocolDecl *D) {
439 if (D->isThisDeclarationADefinition()) {
440 TRY_DECL(D, IndexCtx.handleDecl(D));
441 TRY_TO(handleReferencedProtocols(D->getReferencedProtocols(), D,
443 TRY_TO(IndexCtx.indexDeclContext(D));
445 return IndexCtx.handleReference(D, D->getLocation(), nullptr,
446 D->getDeclContext(), SymbolRoleSet());
451 bool VisitObjCImplementationDecl(const ObjCImplementationDecl *D) {
452 const ObjCInterfaceDecl *Class = D->getClassInterface();
459 TRY_DECL(D, IndexCtx.handleDecl(D));
464 for (const auto *I : D->property_impls()) {
468 for (const auto *I : D->decls()) {
477 bool VisitObjCCategoryDecl(const ObjCCategoryDecl *D) {
478 if (!IndexCtx.shouldIndex(D))
480 const ObjCInterfaceDecl *C = D->getClassInterface();
483 TRY_TO(IndexCtx.handleReference(C, D->getLocation(), D, D, SymbolRoleSet(),
485 (unsigned)SymbolRole::RelationExtendedBy, D
487 SourceLocation CategoryLoc = D->getCategoryNameLoc();
489 CategoryLoc = D->getLocation();
490 TRY_TO(IndexCtx.handleDecl(D, CategoryLoc));
491 TRY_TO(handleReferencedProtocols(D->getReferencedProtocols(), D,
493 TRY_TO(IndexCtx.indexDeclContext(D));
497 bool VisitObjCCategoryImplDecl(const ObjCCategoryImplDecl *D) {
498 const ObjCCategoryDecl *Cat = D->getCategoryDecl();
501 const ObjCInterfaceDecl *C = D->getClassInterface();
503 TRY_TO(IndexCtx.handleReference(C, D->getLocation(), D, D,
505 SourceLocation CategoryLoc = D->getCategoryNameLoc();
507 CategoryLoc = D->getLocation();
508 TRY_DECL(D, IndexCtx.handleDecl(D, CategoryLoc));
509 IndexCtx.indexDeclContext(D);
513 bool VisitObjCMethodDecl(const ObjCMethodDecl *D) {
516 if (D->isPropertyAccessor())
519 handleObjCMethod(D);
523 bool VisitObjCPropertyDecl(const ObjCPropertyDecl *D) {
524 if (ObjCMethodDecl *MD = D->getGetterMethodDecl())
525 if (MD->getLexicalDeclContext() == D->getLexicalDeclContext())
526 handleObjCMethod(MD, D);
527 if (ObjCMethodDecl *MD = D->getSetterMethodDecl())
528 if (MD->getLexicalDeclContext() == D->getLexicalDeclContext())
529 handleObjCMethod(MD, D);
530 TRY_DECL(D, IndexCtx.handleDecl(D));
531 if (IBOutletCollectionAttr *attr = D->getAttr<IBOutletCollectionAttr>())
532 IndexCtx.indexTypeSourceInfo(attr->getInterfaceLoc(), D,
533 D->getLexicalDeclContext(), false, true);
534 IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), D);
538 bool VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D) {
539 ObjCPropertyDecl *PD = D->getPropertyDecl();
540 auto *Container = cast<ObjCImplDecl>(D->getDeclContext());
541 SourceLocation Loc = D->getLocation();
545 if (ObjCIvarDecl *ID = D->getPropertyIvarDecl())
551 TRY_DECL(D, IndexCtx.handleDecl(D, Loc, Roles, Relations));
553 if (D->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic)
556 assert(D->getPropertyImplementation() == ObjCPropertyImplDecl::Synthesize);
567 if (ObjCIvarDecl *IvarD = D->getPropertyIvarDecl()) {
576 SourceLocation IvarLoc = D->getPropertyIvarDeclLoc();
577 if (D->getLocation().isInvalid()) {
580 } else if (D->getLocation() == IvarLoc) {
585 IndexCtx.handleReference(IvarD, D->getPropertyIvarDeclLoc(), nullptr,
586 D->getDeclContext(), SymbolRoleSet());
592 bool VisitNamespaceDecl(const NamespaceDecl *D) {
593 TRY_DECL(D, IndexCtx.handleDecl(D));
594 IndexCtx.indexDeclContext(D);
598 bool VisitNamespaceAliasDecl(const NamespaceAliasDecl *D) {
599 TRY_DECL(D, IndexCtx.handleDecl(D));
600 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), D);
601 IndexCtx.handleReference(D->getAliasedNamespace(), D->getTargetNameLoc(), D,
602 D->getLexicalDeclContext());
606 bool VisitUsingDecl(const UsingDecl *D) {
607 IndexCtx.handleDecl(D);
609 const DeclContext *DC = D->getDeclContext()->getRedeclContext();
611 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
612 D->getLexicalDeclContext());
613 for (const auto *I : D->shadows()) {
620 IndexCtx.handleReference(I->getUnderlyingDecl(), D->getLocation(), Parent,
621 D->getLexicalDeclContext(), SymbolRoleSet());
626 bool VisitUsingDirectiveDecl(const UsingDirectiveDecl *D) {
627 const DeclContext *DC = D->getDeclContext()->getRedeclContext();
632 if (!D->getParentFunctionOrMethod())
633 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
634 D->getLexicalDeclContext());
636 return IndexCtx.handleReference(D->getNominatedNamespaceAsWritten(),
637 D->getLocation(), Parent,
638 D->getLexicalDeclContext(),
642 bool VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D) {
643 TRY_DECL(D, IndexCtx.handleDecl(D));
644 const DeclContext *DC = D->getDeclContext()->getRedeclContext();
646 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
647 D->getLexicalDeclContext());
651 bool VisitUnresolvedUsingTypenameDecl(const UnresolvedUsingTypenameDecl *D) {
652 TRY_DECL(D, IndexCtx.handleDecl(D));
653 const DeclContext *DC = D->getDeclContext()->getRedeclContext();
655 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent,
656 D->getLexicalDeclContext());
661 ClassTemplateSpecializationDecl *D) {
666 Template = D->getSpecializedTemplateOrPartial();
671 if (!D->isThisDeclarationADefinition())
672 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), D);
674 D, SymbolRelation(SymbolRoleSet(SymbolRole::RelationSpecializationOf),
678 D->getTemplateArgsAsWritten()) {
680 handleTemplateArgumentLoc(Arg, D, D->getLexicalDeclContext());
685 static bool shouldIndexTemplateParameterDefaultValue(const NamedDecl *D) {
688 if (!D)
690 if (const auto *FD = dyn_cast<FunctionDecl>(D))
692 else if (const auto *TD = dyn_cast<TagDecl>(D))
694 else if (const auto *VD = dyn_cast<VarDecl>(D))
726 bool VisitTemplateDecl(const TemplateDecl *D) {
727 const NamedDecl *Parent = D->getTemplatedDecl();
732 auto *Params = D->getTemplateParameters();
740 bool VisitConceptDecl(const ConceptDecl *D) {
741 if (auto *Params = D->getTemplateParameters())
742 indexTemplateParameters(Params, D);
743 if (auto *E = D->getConstraintExpr())
744 IndexCtx.indexBody(E, D);
745 return IndexCtx.handleDecl(D);
748 bool VisitFriendDecl(const FriendDecl *D) {
749 if (auto ND = D->getFriendDecl()) {
756 if (isa<ClassTemplateDecl>(ND) && D->getDeclContext()->isDependentContext())
760 if (auto Ty = D->getFriendType()) {
761 IndexCtx.indexTypeSourceInfo(Ty, cast<NamedDecl>(D->getDeclContext()));
766 bool VisitImportDecl(const ImportDecl *D) {
767 return IndexCtx.importedModule(D);
770 bool VisitStaticAssertDecl(const StaticAssertDecl *D) {
771 IndexCtx.indexBody(D->getAssertExpr(),
772 dyn_cast<NamedDecl>(D->getDeclContext()),
773 D->getLexicalDeclContext());
780 bool IndexingContext::indexDecl(const Decl *D) {
781 if (D->isImplicit() && shouldIgnoreIfImplicit(D))
784 if (isTemplateImplicitInstantiation(D) && !shouldIndexImplicitInstantiation())
788 bool ShouldContinue = Visitor.Visit(D);
792 if (!Visitor.Handled && isa<DeclContext>(D))
793 return indexDeclContext(cast<DeclContext>(D));
805 bool IndexingContext::indexTopLevelDecl(const Decl *D) {
806 if (!D || D->getLocation().isInvalid())
809 if (isa<ObjCMethodDecl>(D))
812 if (IndexOpts.ShouldTraverseDecl && !IndexOpts.ShouldTraverseDecl(D))
815 return indexDecl(D);