Lines Matching +full:class +full:- +full:dg
1 //===- IndexDecl.cpp - Indexing declarations ------------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
36 class IndexingDeclVisitor : public ConstDeclVisitor<IndexingDeclVisitor, bool> {
68 if (const NamedDecl *TTD = TD->getTemplatedDecl()) in handleTemplateArgumentLoc()
81 const ObjCMethodDecl *MD = Container->getMethod(D->getSelector(), in hasUserDefined()
82 D->isInstanceMethod()); in hasUserDefined()
83 return MD && !MD->isImplicit() && MD->isThisDeclarationADefinition() && in hasUserDefined()
84 !MD->isSynthesizedAccessorStub(); in hasUserDefined()
93 IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), Parent, in handleDeclarator()
94 Parent->getLexicalDeclContext(), in handleDeclarator()
96 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent); in handleDeclarator()
99 if (Parm->hasDefaultArg() && !Parm->hasUninstantiatedDefaultArg() && in handleDeclarator()
100 !Parm->hasUnparsedDefaultArg()) in handleDeclarator()
101 IndexCtx.indexBody(Parm->getDefaultArg(), Parent); in handleDeclarator()
105 auto *DC = Parm->getDeclContext(); in handleDeclarator()
108 FD->isThisDeclarationADefinition()) in handleDeclarator()
111 if (MD->isThisDeclarationADefinition()) in handleDeclarator()
118 FD->isThisDeclarationADefinition()) { in handleDeclarator()
119 for (const auto *PI : FD->parameters()) { in handleDeclarator()
128 if (FD->isThisDeclarationADefinition()) { in handleDeclarator()
129 for (const auto *PV : FD->parameters()) { in handleDeclarator()
135 if (auto *C = D->getTrailingRequiresClause()) in handleDeclarator()
144 D->getOverriddenMethods(Overriden); in handleObjCMethod()
155 SourceLocation MethodLoc = D->getSelectorStartLoc(); in handleObjCMethod()
157 MethodLoc = D->getLocation(); in handleObjCMethod()
163 bool isGetter = !D->param_size(); in handleObjCMethod()
165 AssociatedProp->getGetterNameLoc(): in handleObjCMethod()
166 AssociatedProp->getSetterNameLoc(); in handleObjCMethod()
170 if (D->isImplicit()) { in handleObjCMethod()
177 IndexCtx.handleReference(D, AttrLoc, cast<NamedDecl>(D->getDeclContext()), in handleObjCMethod()
178 D->getDeclContext(), 0); in handleObjCMethod()
182 IndexCtx.indexTypeSourceInfo(D->getReturnTypeSourceInfo(), D); in handleObjCMethod()
183 bool hasIBActionAndFirst = D->hasAttr<IBActionAttr>(); in handleObjCMethod()
184 for (const auto *I : D->parameters()) { in handleObjCMethod()
189 if (D->isThisDeclarationADefinition()) { in handleObjCMethod()
190 const Stmt *Body = D->getBody(); in handleObjCMethod()
199 /// pseudo-override manner.
201 /// Pseudo-overrides occur when a class template specialization declares
203 /// non-specialized template.
210 dyn_cast<ClassTemplateSpecializationDecl>(D->getLexicalDeclContext()); in gatherTemplatePseudoOverrides()
215 Template = CTSD->getSpecializedTemplateOrPartial(); in gatherTemplatePseudoOverrides()
217 const CXXRecordDecl *Pattern = CTD->getTemplatedDecl(); in gatherTemplatePseudoOverrides()
219 for (const NamedDecl *ND : Pattern->lookup(D->getDeclName())) { in gatherTemplatePseudoOverrides()
221 ND = CTD->getTemplatedDecl(); in gatherTemplatePseudoOverrides()
222 if (ND->isImplicit()) in gatherTemplatePseudoOverrides()
226 if (ND->getKind() != D->getKind()) in gatherTemplatePseudoOverrides()
233 if (FD->getStorageClass() != DFD->getStorageClass() || in gatherTemplatePseudoOverrides()
234 FD->getNumParams() != DFD->getNumParams()) in gatherTemplatePseudoOverrides()
247 if (CXXMD->isVirtual()) in VisitFunctionDecl()
249 for (const CXXMethodDecl *O : CXXMD->overridden_methods()) { in VisitFunctionDecl()
254 if (const auto *Base = D->getPrimaryTemplate()) in VisitFunctionDecl()
257 Base->getTemplatedDecl())); in VisitFunctionDecl()
263 IndexCtx.handleReference(Ctor->getParent(), Ctor->getLocation(), in VisitFunctionDecl()
264 Ctor->getParent(), Ctor->getDeclContext(), in VisitFunctionDecl()
268 for (const auto *Init : Ctor->inits()) { in VisitFunctionDecl()
269 if (Init->isWritten()) { in VisitFunctionDecl()
270 IndexCtx.indexTypeSourceInfo(Init->getTypeSourceInfo(), D); in VisitFunctionDecl()
271 if (const FieldDecl *Member = Init->getAnyMember()) in VisitFunctionDecl()
272 IndexCtx.handleReference(Member, Init->getMemberLocation(), D, D, in VisitFunctionDecl()
274 IndexCtx.indexBody(Init->getInit(), D, D); in VisitFunctionDecl()
278 if (auto TypeNameInfo = Dtor->getNameInfo().getNamedTypeInfo()) { in VisitFunctionDecl()
279 IndexCtx.handleReference(Dtor->getParent(), in VisitFunctionDecl()
280 TypeNameInfo->getTypeLoc().getBeginLoc(), in VisitFunctionDecl()
281 Dtor->getParent(), Dtor->getDeclContext(), in VisitFunctionDecl()
285 IndexCtx.handleReference(Guide->getDeducedTemplate()->getTemplatedDecl(), in VisitFunctionDecl()
286 Guide->getLocation(), Guide, in VisitFunctionDecl()
287 Guide->getDeclContext()); in VisitFunctionDecl()
291 D->getTemplateSpecializationArgsAsWritten()) { in VisitFunctionDecl()
292 for (const auto &Arg : TemplateArgInfo->arguments()) in VisitFunctionDecl()
293 handleTemplateArgumentLoc(Arg, D, D->getLexicalDeclContext()); in VisitFunctionDecl()
296 if (D->isThisDeclarationADefinition()) { in VisitFunctionDecl()
297 const Stmt *Body = D->getBody(); in VisitFunctionDecl()
310 IndexCtx.indexBody(D->getInit(), D); in VisitVarDecl()
315 for (const auto *Binding : D->bindings()) in VisitDecompositionDecl()
325 if (D->isBitField()) in VisitFieldDecl()
326 IndexCtx.indexBody(D->getBitWidth(), D); in VisitFieldDecl()
327 else if (D->hasInClassInitializer()) in VisitFieldDecl()
328 IndexCtx.indexBody(D->getInClassInitializer(), D); in VisitFieldDecl()
333 if (D->getSynthesize()) { in VisitObjCIvarDecl()
350 IndexCtx.indexBody(D->getInitExpr(), D); in VisitEnumConstantDecl()
355 if (!D->isTransparentTag()) { in VisitTypedefNameDecl()
359 IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), D); in VisitTypedefNameDecl()
365 // Non-free standing tags are handled in indexTypeSourceInfo. in VisitTagDecl()
366 if (D->isFreeStanding()) { in VisitTagDecl()
367 if (D->isThisDeclarationADefinition()) { in VisitTagDecl()
374 return IndexCtx.handleDecl(D, D->getLocation(), SymbolRoleSet(), in VisitTagDecl()
375 Relations, D->getLexicalDeclContext()); in VisitTagDecl()
384 // visit integer-base here, which is different than other TagDecl bases. in VisitEnumDecl()
385 if (auto *TSI = ED->getIntegerTypeSourceInfo()) in VisitEnumDecl()
408 if (D->isThisDeclarationADefinition()) { in VisitObjCInterfaceDecl()
410 SourceLocation SuperLoc = D->getSuperClassLoc(); in VisitObjCInterfaceDecl()
411 if (auto *SuperD = D->getSuperClass()) { in VisitObjCInterfaceDecl()
413 if (auto *TInfo = D->getSuperClassTInfo()) { in VisitObjCInterfaceDecl()
414 if (auto *TT = TInfo->getType()->getAs<TypedefType>()) { in VisitObjCInterfaceDecl()
415 if (auto *TD = TT->getDecl()) { in VisitObjCInterfaceDecl()
428 TRY_TO(handleReferencedProtocols(D->getReferencedProtocols(), D, in VisitObjCInterfaceDecl()
432 return IndexCtx.handleReference(D, D->getLocation(), nullptr, in VisitObjCInterfaceDecl()
433 D->getDeclContext(), SymbolRoleSet()); in VisitObjCInterfaceDecl()
439 if (D->isThisDeclarationADefinition()) { in VisitObjCProtocolDecl()
441 TRY_TO(handleReferencedProtocols(D->getReferencedProtocols(), D, in VisitObjCProtocolDecl()
445 return IndexCtx.handleReference(D, D->getLocation(), nullptr, in VisitObjCProtocolDecl()
446 D->getDeclContext(), SymbolRoleSet()); in VisitObjCProtocolDecl()
452 const ObjCInterfaceDecl *Class = D->getClassInterface(); in VisitObjCImplementationDecl() local
453 if (!Class) in VisitObjCImplementationDecl()
456 if (Class->isImplicitInterfaceDecl()) in VisitObjCImplementationDecl()
457 IndexCtx.handleDecl(Class); in VisitObjCImplementationDecl()
463 // serves no purpose other than to simplify the FileCheck-based tests. in VisitObjCImplementationDecl()
464 for (const auto *I : D->property_impls()) { in VisitObjCImplementationDecl()
465 if (I->getLocation().isInvalid()) in VisitObjCImplementationDecl()
468 for (const auto *I : D->decls()) { in VisitObjCImplementationDecl()
470 cast<ObjCPropertyImplDecl>(I)->getLocation().isValid()) in VisitObjCImplementationDecl()
480 const ObjCInterfaceDecl *C = D->getClassInterface(); in VisitObjCCategoryDecl()
483 TRY_TO(IndexCtx.handleReference(C, D->getLocation(), D, D, SymbolRoleSet(), in VisitObjCCategoryDecl()
487 SourceLocation CategoryLoc = D->getCategoryNameLoc(); in VisitObjCCategoryDecl()
489 CategoryLoc = D->getLocation(); in VisitObjCCategoryDecl()
491 TRY_TO(handleReferencedProtocols(D->getReferencedProtocols(), D, in VisitObjCCategoryDecl()
498 const ObjCCategoryDecl *Cat = D->getCategoryDecl(); in VisitObjCCategoryImplDecl()
501 const ObjCInterfaceDecl *C = D->getClassInterface(); in VisitObjCCategoryImplDecl()
503 TRY_TO(IndexCtx.handleReference(C, D->getLocation(), D, D, in VisitObjCCategoryImplDecl()
505 SourceLocation CategoryLoc = D->getCategoryNameLoc(); in VisitObjCCategoryImplDecl()
507 CategoryLoc = D->getLocation(); in VisitObjCCategoryImplDecl()
514 // Methods associated with a property, even user-declared ones, are in VisitObjCMethodDecl()
516 if (D->isPropertyAccessor()) in VisitObjCMethodDecl()
524 if (ObjCMethodDecl *MD = D->getGetterMethodDecl()) in VisitObjCPropertyDecl()
525 if (MD->getLexicalDeclContext() == D->getLexicalDeclContext()) in VisitObjCPropertyDecl()
527 if (ObjCMethodDecl *MD = D->getSetterMethodDecl()) in VisitObjCPropertyDecl()
528 if (MD->getLexicalDeclContext() == D->getLexicalDeclContext()) in VisitObjCPropertyDecl()
531 if (IBOutletCollectionAttr *attr = D->getAttr<IBOutletCollectionAttr>()) in VisitObjCPropertyDecl()
532 IndexCtx.indexTypeSourceInfo(attr->getInterfaceLoc(), D, in VisitObjCPropertyDecl()
533 D->getLexicalDeclContext(), false, true); in VisitObjCPropertyDecl()
534 IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), D); in VisitObjCPropertyDecl()
539 ObjCPropertyDecl *PD = D->getPropertyDecl(); in VisitObjCPropertyImplDecl()
540 auto *Container = cast<ObjCImplDecl>(D->getDeclContext()); in VisitObjCPropertyImplDecl()
541 SourceLocation Loc = D->getLocation(); in VisitObjCPropertyImplDecl()
545 if (ObjCIvarDecl *ID = D->getPropertyIvarDecl()) in VisitObjCPropertyImplDecl()
548 Loc = Container->getLocation(); in VisitObjCPropertyImplDecl()
553 if (D->getPropertyImplementation() == ObjCPropertyImplDecl::Dynamic) in VisitObjCPropertyImplDecl()
556 assert(D->getPropertyImplementation() == ObjCPropertyImplDecl::Synthesize); in VisitObjCPropertyImplDecl()
559 if (ObjCMethodDecl *MD = PD->getGetterMethodDecl()) { in VisitObjCPropertyImplDecl()
560 if (MD->isPropertyAccessor() && !hasUserDefined(MD, Container)) in VisitObjCPropertyImplDecl()
563 if (ObjCMethodDecl *MD = PD->getSetterMethodDecl()) { in VisitObjCPropertyImplDecl()
564 if (MD->isPropertyAccessor() && !hasUserDefined(MD, Container)) in VisitObjCPropertyImplDecl()
567 if (ObjCIvarDecl *IvarD = D->getPropertyIvarDecl()) { in VisitObjCPropertyImplDecl()
568 if (IvarD->getSynthesize()) { in VisitObjCPropertyImplDecl()
576 SourceLocation IvarLoc = D->getPropertyIvarDeclLoc(); in VisitObjCPropertyImplDecl()
577 if (D->getLocation().isInvalid()) { in VisitObjCPropertyImplDecl()
578 IvarLoc = Container->getLocation(); in VisitObjCPropertyImplDecl()
580 } else if (D->getLocation() == IvarLoc) { in VisitObjCPropertyImplDecl()
585 IndexCtx.handleReference(IvarD, D->getPropertyIvarDeclLoc(), nullptr, in VisitObjCPropertyImplDecl()
586 D->getDeclContext(), SymbolRoleSet()); in VisitObjCPropertyImplDecl()
600 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), D); in VisitNamespaceAliasDecl()
601 IndexCtx.handleReference(D->getAliasedNamespace(), D->getTargetNameLoc(), D, in VisitNamespaceAliasDecl()
602 D->getLexicalDeclContext()); in VisitNamespaceAliasDecl()
609 const DeclContext *DC = D->getDeclContext()->getRedeclContext(); in VisitUsingDecl()
611 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent, in VisitUsingDecl()
612 D->getLexicalDeclContext()); in VisitUsingDecl()
613 for (const auto *I : D->shadows()) { in VisitUsingDecl()
614 // Skip unresolved using decls - we already have a decl for the using in VisitUsingDecl()
617 if (isa<UnresolvedUsingIfExistsDecl>(I->getUnderlyingDecl())) in VisitUsingDecl()
620 IndexCtx.handleReference(I->getUnderlyingDecl(), D->getLocation(), Parent, in VisitUsingDecl()
621 D->getLexicalDeclContext(), SymbolRoleSet()); in VisitUsingDecl()
627 const DeclContext *DC = D->getDeclContext()->getRedeclContext(); in VisitUsingDirectiveDecl()
632 if (!D->getParentFunctionOrMethod()) in VisitUsingDirectiveDecl()
633 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent, in VisitUsingDirectiveDecl()
634 D->getLexicalDeclContext()); in VisitUsingDirectiveDecl()
636 return IndexCtx.handleReference(D->getNominatedNamespaceAsWritten(), in VisitUsingDirectiveDecl()
637 D->getLocation(), Parent, in VisitUsingDirectiveDecl()
638 D->getLexicalDeclContext(), in VisitUsingDirectiveDecl()
644 const DeclContext *DC = D->getDeclContext()->getRedeclContext(); in VisitUnresolvedUsingValueDecl()
646 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent, in VisitUnresolvedUsingValueDecl()
647 D->getLexicalDeclContext()); in VisitUnresolvedUsingValueDecl()
653 const DeclContext *DC = D->getDeclContext()->getRedeclContext(); in VisitUnresolvedUsingTypenameDecl()
655 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent, in VisitUnresolvedUsingTypenameDecl()
656 D->getLexicalDeclContext()); in VisitUnresolvedUsingTypenameDecl()
666 Template = D->getSpecializedTemplateOrPartial(); in VisitClassTemplateSpecializationDecl()
671 if (!D->isThisDeclarationADefinition()) in VisitClassTemplateSpecializationDecl()
672 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), D); in VisitClassTemplateSpecializationDecl()
678 D->getTemplateArgsAsWritten()) { in VisitClassTemplateSpecializationDecl()
679 for (const auto &Arg : TemplateArgInfo->arguments()) in VisitClassTemplateSpecializationDecl()
680 handleTemplateArgumentLoc(Arg, D, D->getLexicalDeclContext()); in VisitClassTemplateSpecializationDecl()
691 return FD->getCanonicalDecl() == FD; in shouldIndexTemplateParameterDefaultValue()
693 return TD->getCanonicalDecl() == TD; in shouldIndexTemplateParameterDefaultValue()
695 return VD->getCanonicalDecl() == VD; in shouldIndexTemplateParameterDefaultValue()
705 if (TTP->hasDefaultArgument()) in indexTemplateParameters()
706 handleTemplateArgumentLoc(TTP->getDefaultArgument(), Parent, in indexTemplateParameters()
707 TP->getLexicalDeclContext()); in indexTemplateParameters()
708 if (auto *C = TTP->getTypeConstraint()) in indexTemplateParameters()
709 IndexCtx.handleReference(C->getNamedConcept(), C->getConceptNameLoc(), in indexTemplateParameters()
710 Parent, TTP->getLexicalDeclContext()); in indexTemplateParameters()
712 IndexCtx.indexTypeSourceInfo(NTTP->getTypeSourceInfo(), Parent); in indexTemplateParameters()
713 if (NTTP->hasDefaultArgument()) in indexTemplateParameters()
714 handleTemplateArgumentLoc(NTTP->getDefaultArgument(), Parent, in indexTemplateParameters()
715 TP->getLexicalDeclContext()); in indexTemplateParameters()
717 if (TTPD->hasDefaultArgument()) in indexTemplateParameters()
718 handleTemplateArgumentLoc(TTPD->getDefaultArgument(), Parent, in indexTemplateParameters()
719 TP->getLexicalDeclContext()); in indexTemplateParameters()
722 if (auto *R = Params->getRequiresClause()) in indexTemplateParameters()
727 const NamedDecl *Parent = D->getTemplatedDecl(); in VisitTemplateDecl()
732 auto *Params = D->getTemplateParameters(); in VisitTemplateDecl()
741 if (auto *Params = D->getTemplateParameters()) in VisitConceptDecl()
743 if (auto *E = D->getConstraintExpr()) in VisitConceptDecl()
749 if (auto ND = D->getFriendDecl()) { in VisitFriendDecl()
750 // FIXME: Ignore a class template in a dependent context, these are not in VisitFriendDecl()
756 if (isa<ClassTemplateDecl>(ND) && D->getDeclContext()->isDependentContext()) in VisitFriendDecl()
760 if (auto Ty = D->getFriendType()) { in VisitFriendDecl()
761 IndexCtx.indexTypeSourceInfo(Ty, cast<NamedDecl>(D->getDeclContext())); in VisitFriendDecl()
771 IndexCtx.indexBody(D->getAssertExpr(), in VisitStaticAssertDecl()
772 dyn_cast<NamedDecl>(D->getDeclContext()), in VisitStaticAssertDecl()
773 D->getLexicalDeclContext()); in VisitStaticAssertDecl()
781 if (D->isImplicit() && shouldIgnoreIfImplicit(D)) in indexDecl()
799 for (const auto *I : DC->decls()) in indexDeclContext()
806 if (!D || D->getLocation().isInvalid()) in indexTopLevelDecl()
818 bool IndexingContext::indexDeclGroupRef(DeclGroupRef DG) { in indexDeclGroupRef() argument
819 for (DeclGroupRef::iterator I = DG.begin(), E = DG.end(); I != E; ++I) in indexDeclGroupRef()