;
21#define TRY_DECL(D,CALL_EXPR) \ 23 if (!IndexCtx.shouldIndex(D)) return true; \ 28#define TRY_TO(CALL_EXPR) \ 36classIndexingDeclVisitor :
public ConstDeclVisitor<IndexingDeclVisitor, bool> {
41: IndexCtx(indexCtx) { }
68 if(
const NamedDecl*TTD = TD->getTemplatedDecl())
82 D->isInstanceMethod());
90 boolisIBType =
false) {
94 Parent->getLexicalDeclContext(),
97 autoIndexDefaultParmeterArgument = [&](
const ParmVarDecl*Parm,
104 if(
const ParmVarDecl*Parm = dyn_cast<ParmVarDecl>(
D)) {
106 if(
auto*FD = dyn_cast<FunctionDecl>(DC)) {
108FD->isThisDeclarationADefinition())
110}
else if(
auto*MD = dyn_cast<ObjCMethodDecl>(DC)) {
111 if(MD->isThisDeclarationADefinition())
116}
else if(
const FunctionDecl*FD = dyn_cast<FunctionDecl>(
D)) {
118FD->isThisDeclarationADefinition()) {
119 for(
const auto*PI : FD->parameters()) {
120IndexDefaultParmeterArgument(PI,
D);
127 if(
const auto*FD = dyn_cast<FunctionDecl>(
D)) {
128 if(FD->isThisDeclarationADefinition()) {
129 for(
const auto*PV : FD->parameters()) {
130IndexDefaultParmeterArgument(PV,
D);
135 if(
auto*
C=
D->getTrailingRequiresClause())
144 D->getOverriddenMethods(Overriden);
145 for(
autooverridden: Overriden) {
146Relations.emplace_back((
unsigned) SymbolRole::RelationOverrideOf,
150Relations.emplace_back((
unsigned)SymbolRole::RelationAccessorOf,
162 if(AssociatedProp) {
163 boolisGetter = !
D->param_size();
165AssociatedProp->getGetterNameLoc():
166AssociatedProp->getSetterNameLoc();
176}
else if(AttrLoc.
isValid()) {
183 boolhasIBActionAndFirst =
D->
hasAttr<IBActionAttr>();
184 for(
const auto*I :
D->parameters()) {
185handleDeclarator(I,
D,
hasIBActionAndFirst);
186hasIBActionAndFirst =
false;
189 if(
D->isThisDeclarationADefinition()) {
205gatherTemplatePseudoOverrides(
const NamedDecl*
D,
218 boolTypeOverride = isa<TypeDecl>(
D);
220 if(
const auto*CTD = dyn_cast<ClassTemplateDecl>(ND))
221ND = CTD->getTemplatedDecl();
222 if(ND->isImplicit())
226 if(ND->getKind() !=
D->
getKind())
228}
else if(!isa<TypeDecl>(ND))
230 if(
const auto*FD = dyn_cast<FunctionDecl>(ND)) {
231 const auto*DFD = cast<FunctionDecl>(
D);
233 if(FD->getStorageClass() != DFD->getStorageClass() ||
234FD->getNumParams() != DFD->getNumParams())
237Relations.emplace_back(
246 if(
auto*CXXMD = dyn_cast<CXXMethodDecl>(
D)) {
247 if(CXXMD->isVirtual())
248Roles |= (
unsigned)SymbolRole::Dynamic;
250Relations.emplace_back((
unsigned)SymbolRole::RelationOverrideOf, O);
253gatherTemplatePseudoOverrides(
D, Relations);
254 if(
const auto*
Base=
D->getPrimaryTemplate())
257 Base->getTemplatedDecl()));
260handleDeclarator(
D);
264Ctor->getParent(), Ctor->getDeclContext(),
265(
unsigned)SymbolRole::NameReference);
268 for(
const auto*
Init: Ctor->inits()) {
269 if(
Init->isWritten()) {
273(
unsigned)SymbolRole::Write);
278 if(
autoTypeNameInfo = Dtor->getNameInfo().getNamedTypeInfo()) {
280TypeNameInfo->getTypeLoc().getBeginLoc(),
281Dtor->getParent(), Dtor->getDeclContext(),
282(
unsigned)SymbolRole::NameReference);
284}
else if(
const auto*Guide = dyn_cast<CXXDeductionGuideDecl>(
D)) {
285IndexCtx.
handleReference(Guide->getDeducedTemplate()->getTemplatedDecl(),
286Guide->getLocation(), Guide,
287Guide->getDeclContext());
291 D->getTemplateSpecializationArgsAsWritten()) {
292 for(
const auto&Arg : TemplateArgInfo->arguments())
296 if(
D->isThisDeclarationADefinition()) {
305 boolVisitVarDecl(
const VarDecl*
D) {
307gatherTemplatePseudoOverrides(
D, Relations);
309handleDeclarator(
D);
315 for(
const auto*Binding :
D->bindings())
317 returnBase::VisitDecompositionDecl(
D);
322gatherTemplatePseudoOverrides(
D, Relations);
324handleDeclarator(
D);
325 if(
D->isBitField())
327 else if(
D->hasInClassInitializer())
328IndexCtx.
indexBody(
D->getInClassInitializer(),
D);
333 if(
D->getSynthesize()) {
338handleDeclarator(
D);
344handleDeclarator(
D);
355 if(!
D->isTransparentTag()) {
357gatherTemplatePseudoOverrides(
D, Relations);
364 boolVisitTagDecl(
const TagDecl*
D) {
366 if(
D->isFreeStanding()) {
367 if(
D->isThisDeclarationADefinition()) {
369gatherTemplatePseudoOverrides(
D, Relations);
373gatherTemplatePseudoOverrides(
D, Relations);
381 boolVisitEnumDecl(
const EnumDecl*ED) {
382 TRY_TO(VisitTagDecl(ED));
395I = ProtList.
begin(),
E= ProtList.
end(); I !=
E; ++I, ++LI) {
399 if(
Loc== SuperLoc)
408 if(
D->isThisDeclarationADefinition()) {
411 if(
auto*SuperD =
D->getSuperClass()) {
412 boolhasSuperTypedef =
false;
413 if(
auto*TInfo =
D->getSuperClassTInfo()) {
414 if(
auto*TT = TInfo->getType()->getAs<
TypedefType>()) {
415 if(
auto*TD = TT->getDecl()) {
416hasSuperTypedef =
true;
428 TRY_TO(handleReferencedProtocols(
D->getReferencedProtocols(),
D,
439 if(
D->isThisDeclarationADefinition()) {
441 TRY_TO(handleReferencedProtocols(
D->getReferencedProtocols(),
D,
456 if(
Class->isImplicitInterfaceDecl())
464 for(
const auto*I :
D->property_impls()) {
465 if(I->getLocation().isInvalid())
468 for(
const auto*I :
D->decls()) {
469 if(!isa<ObjCPropertyImplDecl>(I) ||
470cast<ObjCPropertyImplDecl>(I)->getLocation().isValid())
485(
unsigned)SymbolRole::RelationExtendedBy,
D 491 TRY_TO(handleReferencedProtocols(
D->getReferencedProtocols(),
D,
516 if(
D->isPropertyAccessor())
519handleObjCMethod(
D);
526handleObjCMethod(MD,
D);
529handleObjCMethod(MD,
D);
531 if(IBOutletCollectionAttr *
attr=
D->
getAttr<IBOutletCollectionAttr>())
546Relations.push_back({(
SymbolRoleSet)SymbolRole::RelationAccessorOf, ID});
548 Loc= Container->getLocation();
560 if(MD->isPropertyAccessor() && !hasUserDefined(MD, Container))
561IndexCtx.
handleDecl(MD,
Loc, AccessorMethodRoles, {}, Container);
564 if(MD->isPropertyAccessor() && !hasUserDefined(MD, Container))
565IndexCtx.
handleDecl(MD,
Loc, AccessorMethodRoles, {}, Container);
568 if(IvarD->getSynthesize()) {
578IvarLoc = Container->getLocation();
613 for(
const auto*I :
D->shadows()) {
617 if(isa<UnresolvedUsingIfExistsDecl>(I->getUnderlyingDecl()))
660 boolVisitClassTemplateSpecializationDecl(
const 666Template =
D->getSpecializedTemplateOrPartial();
667 const Decl*SpecializationOf =
668isa<ClassTemplateDecl *>(Template)
669? (
Decl*)cast<ClassTemplateDecl *>(Template)
670: cast<ClassTemplatePartialSpecializationDecl *>(Template);
671 if(!
D->isThisDeclarationADefinition())
678 D->getTemplateArgsAsWritten()) {
679 for(
const auto&Arg : TemplateArgInfo->arguments())
685 static boolshouldIndexTemplateParameterDefaultValue(
const NamedDecl*
D) {
690 if(
const auto*FD = dyn_cast<FunctionDecl>(
D))
691 returnFD->getCanonicalDecl() == FD;
692 else if(
const auto*TD = dyn_cast<TagDecl>(
D))
693 returnTD->getCanonicalDecl() == TD;
694 else if(
const auto*VD = dyn_cast<VarDecl>(
D))
695 returnVD->getCanonicalDecl() == VD;
704 if(
const auto*TTP = dyn_cast<TemplateTypeParmDecl>(TP)) {
705 if(TTP->hasDefaultArgument())
706handleTemplateArgumentLoc(TTP->getDefaultArgument(),
Parent,
707TP->getLexicalDeclContext());
708 if(
auto*
C= TTP->getTypeConstraint())
710 Parent, TTP->getLexicalDeclContext());
711}
else if(
const auto*NTTP = dyn_cast<NonTypeTemplateParmDecl>(TP)) {
713 if(NTTP->hasDefaultArgument())
714handleTemplateArgumentLoc(NTTP->getDefaultArgument(),
Parent,
715TP->getLexicalDeclContext());
716}
else if(
const auto*TTPD = dyn_cast<TemplateTemplateParmDecl>(TP)) {
717 if(TTPD->hasDefaultArgument())
718handleTemplateArgumentLoc(TTPD->getDefaultArgument(),
Parent,
719TP->getLexicalDeclContext());
722 if(
auto*R = Params->getRequiresClause())
732 auto*Params =
D->getTemplateParameters();
733 if(Params && shouldIndexTemplateParameterDefaultValue(
Parent)) {
734indexTemplateParameters(Params,
Parent);
741 if(
auto*Params =
D->getTemplateParameters())
742indexTemplateParameters(Params,
D);
743 if(
auto*
E=
D->getConstraintExpr())
749 if(
autoND =
D->getFriendDecl()) {
760 if(
autoTy =
D->getFriendType()) {
787IndexingDeclVisitor Visitor(*
this);
788 boolShouldContinue = Visitor.Visit(
D);
792 if(!Visitor.Handled && isa<DeclContext>(
D))
799 for(
const auto*I : DC->
decls())
809 if(isa<ObjCMethodDecl>(
D))
This file provides AST data structures related to concepts.
Defines the C++ template declaration subclasses.
#define TRY_DECL(D, CALL_EXPR)
#define TRY_TO(CALL_EXPR)
Represents a C++ constructor within a class.
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
overridden_method_range overridden_methods() const
Represents a C++ struct/union/class.
Declaration of a class template.
Represents a class template specialization, which refers to a class template with a given set of temp...
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this.
Declaration of a C++20 concept.
A simple visitor class that helps create declaration visitors.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Decl - This represents one declaration (or definition), e.g.
const DeclContext * getParentFunctionOrMethod(bool LexicalParent=false) const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext,...
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
SourceLocation getLocation() const
DeclContext * getDeclContext()
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Represents a ValueDecl that came out of a declarator.
A decomposition declaration.
An instance of this object exists for each enum constant that is defined.
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists,...
Represents a member of a struct/union/class.
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Represents a function declaration or definition.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
An instance of this class represents the declaration of a property member.
This represents a decl that may have a name.
Represents a C++ namespace alias.
Represent a C++ namespace.
ObjCCategoryDecl - Represents a category declaration.
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
ObjCContainerDecl - Represents a container for method declarations.
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Represents an ObjC class declaration.
ObjCProtocolList::iterator protocol_iterator
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCMethodDecl - Represents an instance or class method declaration.
bool isSynthesizedAccessorStub() const
bool isThisDeclarationADefinition() const
Returns whether this specific method is a definition.
Represents one property declaration in an Objective-C interface.
ObjCMethodDecl * getGetterMethodDecl() const
ObjCMethodDecl * getSetterMethodDecl() const
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Represents an Objective-C protocol declaration.
A list of Objective-C protocols, along with the source locations at which they were referenced.
loc_iterator loc_begin() const
Represents a parameter to a function.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
bool hasUninstantiatedDefaultArg() const
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
Represents a C++11 static_assert declaration.
Stmt - This represents one statement.
Represents the declaration of a struct/union/class/enum.
Location wrapper for a TemplateArgument.
TemplateArgumentLocInfo getLocInfo() const
const TemplateArgument & getArgument() const
SourceLocation getTemplateNameLoc() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
@ Template
The template argument is a template name that was provided for a template template parameter.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ Type
The template argument is a type.
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
Stores a list of template parameters for a TemplateDecl and its derived classes.
Base class for declarations which introduce a typedef-name.
Represents a dependent using declaration which was marked with typename.
Represents a dependent using declaration which was not marked with typename.
Represents a C++ using-declaration.
Represents C++ using-directive.
Represents a variable declaration or definition.
RetTy VisitDecl(PTR(Decl) D)
bool shouldIndexImplicitInstantiation() const
bool importedModule(const ImportDecl *ImportD)
bool handleDecl(const Decl *D, SymbolRoleSet Roles=SymbolRoleSet(), ArrayRef< SymbolRelation > Relations={})
bool shouldIndex(const Decl *D)
bool indexDeclContext(const DeclContext *DC)
bool handleReference(const NamedDecl *D, SourceLocation Loc, const NamedDecl *Parent, const DeclContext *DC, SymbolRoleSet Roles=SymbolRoleSet(), ArrayRef< SymbolRelation > Relations={}, const Expr *RefE=nullptr)
void indexTagDecl(const TagDecl *D, ArrayRef< SymbolRelation > Relations={})
bool shouldIndexFunctionLocalSymbols() const
void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const NamedDecl *Parent, const DeclContext *DC=nullptr)
bool indexTopLevelDecl(const Decl *D)
bool shouldIndexTemplateParameters() const
void indexBody(const Stmt *S, const NamedDecl *Parent, const DeclContext *DC=nullptr)
bool shouldIndexParametersInDeclarations() const
bool indexDeclGroupRef(DeclGroupRef DG)
static bool isTemplateImplicitInstantiation(const Decl *D)
const LangOptions & getLangOpts() const
bool indexDecl(const Decl *D)
void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent, const DeclContext *DC=nullptr, bool isBase=false, bool isIBType=false)
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
The JSON file list parser is used to communicate input to InstallAPI.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Location information for a TemplateArgument.
TypeSourceInfo * getAsTypeSourceInfo() const
std::function< bool(const Decl *)> ShouldTraverseDecl
Represents a relation to another symbol for a symbol occurrence.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4