14#include "llvm/ADT/ScopeExit.h"
33 : IndexCtx(indexCtx),
Parent(parent), ParentDC(DC), IsBase(isBase) {
36 Relations.emplace_back((
unsigned)SymbolRole::RelationBaseOf, Parent);
40 Relations.emplace_back((
unsigned)SymbolRole::RelationIBTypeOf, Parent);
46#define TRY_TO(CALL_EXPR) \
72 (
unsigned)SymbolRole::Implicit,
92 if (
D->getTypeSourceInfo())
105 if (FD->isThisDeclarationADefinition()) {
106 return traverseParamVarHelper(
D);
110 return base::TraverseParmVarDecl(
D);
147 void HandleTemplateSpecializationTypeLoc(
TemplateName TemplName,
153 if (!IsTypeAlias && ResolvedClass &&
156 IndexCtx.
handleReference(ResolvedClass, TemplNameLoc, Parent, ParentDC,
168 HandleTemplateSpecializationTypeLoc(
175 if (!WalkUpFromTemplateSpecializationTypeLoc(TL))
184 auto ResetSavedRelations =
185 llvm::make_scope_exit([&] { this->Relations = SavedRelations; });
186 for (
unsigned I = 0,
E = TL.
getNumArgs(); I !=
E; ++I) {
198 HandleTemplateSpecializationTypeLoc(
230 Name, [](
const NamedDecl *ND) {
return isa<TypeDecl>(ND); });
231 if (Symbols.size() != 1)
265 DC =
Parent->getLexicalDeclContext();
266 TypeIndexer(*
this,
Parent, DC, isBase, isIBType).TraverseTypeLoc(TL);
279 DC =
Parent->getLexicalDeclContext();
312 if (
D->isThisDeclarationADefinition()) {
314 if (
auto CXXRD = dyn_cast<CXXRecordDecl>(
D)) {
315 for (
const auto &I : CXXRD->bases()) {
This file provides AST data structures related to concepts.
#define TRY_TO(CALL_EXPR)
Defines the clang::TypeLoc interface and its subclasses.
ConceptDecl * getNamedConcept() const
SourceLocation getConceptNameLoc() const
Represents a C++ struct/union/class.
CXXRecordDecl * getDefinition() const
bool hasDefinition() const
std::vector< const NamedDecl * > lookupDependentName(DeclarationName Name, llvm::function_ref< bool(const NamedDecl *ND)> Filter)
Performs an imprecise lookup of a dependent name in this class.
Declaration of a class template.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
const TypeClass * getTypePtr() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
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.
DeclContext * getDeclContext()
The name of a declaration.
SourceLocation getTemplateNameLoc() const
SourceLocation getNameLoc() const
Represents a qualified type name for which the type name is dependent.
NestedNameSpecifier * getQualifier() const
Retrieve the qualification on this type.
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
const TypeClass * getTypePtr() const
Wrapper for source info for injected class names of class templates.
CXXRecordDecl * getDecl() const
This represents a decl that may have a name.
A C++ nested-name-specifier augmented with source location information.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
@ TypeSpec
A type, stored as a Type*.
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Identifier
An identifier, stored as an IdentifierInfo*.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace, stored as a NamespaceDecl*.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Wrapper for source info for ObjC interfaces.
ObjCInterfaceDecl * getIFaceDecl() const
SourceLocation getNameLoc() const
ObjCProtocolDecl * getProtocol(unsigned i) const
unsigned getNumProtocols() const
SourceLocation getProtocolLoc(unsigned i) const
Represents a parameter to a function.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc)
Recursively visit a template argument location and dispatch to the appropriate method for the argumen...
bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Recursively visit a C++ nested-name-specifier with location information.
bool TraverseTemplateName(TemplateName Template)
Recursively visit a template name and dispatch to the appropriate method.
bool TraverseStmt(Stmt *S, DataRecursionQueue *Queue=nullptr)
Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dy...
bool TraverseTypeLoc(TypeLoc TL)
Recursively visit a type with location, by dispatching to Traverse*TypeLoc() based on the argument ty...
bool shouldWalkTypesOfTypeLocs() const
Return whether this visitor should recurse into the types of TypeLocs.
Encodes a location in the source.
Stmt - This represents one statement.
Represents the declaration of a struct/union/class/enum.
Wrapper for source info for tag types.
TagDecl * getDecl() const
bool isDefinition() const
True if the tag was defined in this type specifier.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
unsigned getNumArgs() const
TemplateArgumentLoc getArgLoc(unsigned i) const
SourceLocation getTemplateNameLoc() const
Represents a type template specialization; the template must be a class template, a type alias templa...
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Declaration of a template type parameter.
Wrapper for template type parameters.
TemplateTypeParmDecl * getDecl() const
Base wrapper for a particular "section" of type source info.
QualType getType() const
Get the type for which this source info wrapper provides information.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
SourceLocation getNameLoc() const
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
const T * getAs() const
Member-template getAs<specific type>'.
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
Base class for declarations which introduce a typedef-name.
QualType getUnderlyingType() const
bool isTransparentTag() const
Determines if this typedef shares a name and spelling location with its underlying tag type,...
Wrapper for source info for typedefs.
TypedefNameDecl * getTypedefNameDecl() const
bool shouldIndexImplicitInstantiation() const
bool shouldIndex(const Decl *D)
bool indexDeclContext(const DeclContext *DC)
bool shouldIndexFunctionLocalSymbols() const
void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const NamedDecl *Parent, const DeclContext *DC=nullptr)
void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent, const DeclContext *DC=nullptr, bool isBase=false, bool isIBType=false)
bool handleReference(const NamedDecl *D, SourceLocation Loc, const NamedDecl *Parent, const DeclContext *DC, SymbolRoleSet Roles=SymbolRoleSet(), ArrayRef< SymbolRelation > Relations=std::nullopt, const Expr *RefE=nullptr)
void indexBody(const Stmt *S, const NamedDecl *Parent, const DeclContext *DC=nullptr)
void indexTagDecl(const TagDecl *D, ArrayRef< SymbolRelation > Relations=std::nullopt)
void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent, const DeclContext *DC=nullptr, bool isBase=false, bool isIBType=false)
bool handleDecl(const Decl *D, SymbolRoleSet Roles=SymbolRoleSet(), ArrayRef< SymbolRelation > Relations=std::nullopt)
bool isFunctionLocalSymbol(const Decl *D)
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T