clang  16.0.0git
IndexDecl.cpp
Go to the documentation of this file.
1 //===- IndexDecl.cpp - Indexing declarations ------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "IndexingContext.h"
10 #include "clang/AST/ASTConcept.h"
11 #include "clang/AST/Attr.h"
12 #include "clang/AST/Decl.h"
13 #include "clang/AST/DeclTemplate.h"
14 #include "clang/AST/DeclVisitor.h"
17 
18 using namespace clang;
19 using namespace index;
20 
21 #define TRY_DECL(D,CALL_EXPR) \
22  do { \
23  if (!IndexCtx.shouldIndex(D)) return true; \
24  if (!CALL_EXPR) \
25  return false; \
26  } while (0)
27 
28 #define TRY_TO(CALL_EXPR) \
29  do { \
30  if (!CALL_EXPR) \
31  return false; \
32  } while (0)
33 
34 namespace {
35 
36 class IndexingDeclVisitor : public ConstDeclVisitor<IndexingDeclVisitor, bool> {
37  IndexingContext &IndexCtx;
38 
39 public:
40  explicit IndexingDeclVisitor(IndexingContext &indexCtx)
41  : IndexCtx(indexCtx) { }
42 
43  bool Handled = true;
44 
45  bool VisitDecl(const Decl *D) {
46  Handled = false;
47  return true;
48  }
49 
50  void handleTemplateArgumentLoc(const TemplateArgumentLoc &TALoc,
51  const NamedDecl *Parent,
52  const DeclContext *DC) {
53  const TemplateArgumentLocInfo &LocInfo = TALoc.getLocInfo();
54  switch (TALoc.getArgument().getKind()) {
56  IndexCtx.indexBody(LocInfo.getAsExpr(), Parent, DC);
57  break;
59  IndexCtx.indexTypeSourceInfo(LocInfo.getAsTypeSourceInfo(), Parent, DC);
60  break;
64  Parent, DC);
65  if (const TemplateDecl *TD = TALoc.getArgument()
67  .getAsTemplateDecl()) {
68  if (const NamedDecl *TTD = TD->getTemplatedDecl())
69  IndexCtx.handleReference(TTD, TALoc.getTemplateNameLoc(), Parent, DC);
70  }
71  break;
72  default:
73  break;
74  }
75  }
76 
77  /// Returns true if the given method has been defined explicitly by the
78  /// user.
79  static bool hasUserDefined(const ObjCMethodDecl *D,
80  const ObjCImplDecl *Container) {
81  const ObjCMethodDecl *MD = Container->getMethod(D->getSelector(),
82  D->isInstanceMethod());
83  return MD && !MD->isImplicit() && MD->isThisDeclarationADefinition() &&
85  }
86 
87 
88  void handleDeclarator(const DeclaratorDecl *D,
89  const NamedDecl *Parent = nullptr,
90  bool isIBType = false) {
91  if (!Parent) Parent = D;
92 
94  Parent->getLexicalDeclContext(),
95  /*isBase=*/false, isIBType);
97  auto IndexDefaultParmeterArgument = [&](const ParmVarDecl *Parm,
98  const NamedDecl *Parent) {
99  if (Parm->hasDefaultArg() && !Parm->hasUninstantiatedDefaultArg() &&
100  !Parm->hasUnparsedDefaultArg())
101  IndexCtx.indexBody(Parm->getDefaultArg(), Parent);
102  };
103  if (IndexCtx.shouldIndexFunctionLocalSymbols()) {
104  if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
105  auto *DC = Parm->getDeclContext();
106  if (auto *FD = dyn_cast<FunctionDecl>(DC)) {
107  if (IndexCtx.shouldIndexParametersInDeclarations() ||
108  FD->isThisDeclarationADefinition())
109  IndexCtx.handleDecl(Parm);
110  } else if (auto *MD = dyn_cast<ObjCMethodDecl>(DC)) {
111  if (MD->isThisDeclarationADefinition())
112  IndexCtx.handleDecl(Parm);
113  } else {
114  IndexCtx.handleDecl(Parm);
115  }
116  } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
117  if (IndexCtx.shouldIndexParametersInDeclarations() ||
118  FD->isThisDeclarationADefinition()) {
119  for (const auto *PI : FD->parameters()) {
120  IndexDefaultParmeterArgument(PI, D);
121  IndexCtx.handleDecl(PI);
122  }
123  }
124  }
125  } else {
126  // Index the default parameter value for function definitions.
127  if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
128  if (FD->isThisDeclarationADefinition()) {
129  for (const auto *PV : FD->parameters()) {
130  IndexDefaultParmeterArgument(PV, D);
131  }
132  }
133  }
134  }
135  if (auto *C = D->getTrailingRequiresClause())
136  IndexCtx.indexBody(C, Parent);
137  }
138 
139  bool handleObjCMethod(const ObjCMethodDecl *D,
140  const ObjCPropertyDecl *AssociatedProp = nullptr) {
143 
144  D->getOverriddenMethods(Overriden);
145  for(auto overridden: Overriden) {
146  Relations.emplace_back((unsigned) SymbolRole::RelationOverrideOf,
147  overridden);
148  }
149  if (AssociatedProp)
150  Relations.emplace_back((unsigned)SymbolRole::RelationAccessorOf,
151  AssociatedProp);
152 
153  // getLocation() returns beginning token of a method declaration, but for
154  // indexing purposes we want to point to the base name.
155  SourceLocation MethodLoc = D->getSelectorStartLoc();
156  if (MethodLoc.isInvalid())
157  MethodLoc = D->getLocation();
158 
159  SourceLocation AttrLoc;
160 
161  // check for (getter=/setter=)
162  if (AssociatedProp) {
163  bool isGetter = !D->param_size();
164  AttrLoc = isGetter ?
165  AssociatedProp->getGetterNameLoc():
166  AssociatedProp->getSetterNameLoc();
167  }
168 
170  if (D->isImplicit()) {
171  if (AttrLoc.isValid()) {
172  MethodLoc = AttrLoc;
173  } else {
175  }
176  } else if (AttrLoc.isValid()) {
177  IndexCtx.handleReference(D, AttrLoc, cast<NamedDecl>(D->getDeclContext()),
178  D->getDeclContext(), 0);
179  }
180 
181  TRY_DECL(D, IndexCtx.handleDecl(D, MethodLoc, Roles, Relations));
183  bool hasIBActionAndFirst = D->hasAttr<IBActionAttr>();
184  for (const auto *I : D->parameters()) {
185  handleDeclarator(I, D, /*isIBType=*/hasIBActionAndFirst);
186  hasIBActionAndFirst = false;
187  }
188 
189  if (D->isThisDeclarationADefinition()) {
190  const Stmt *Body = D->getBody();
191  if (Body) {
192  IndexCtx.indexBody(Body, D, D);
193  }
194  }
195  return true;
196  }
197 
198  /// Gather the declarations which the given declaration \D overrides in a
199  /// pseudo-override manner.
200  ///
201  /// Pseudo-overrides occur when a class template specialization declares
202  /// a declaration that has the same name as a similar declaration in the
203  /// non-specialized template.
204  void
205  gatherTemplatePseudoOverrides(const NamedDecl *D,
206  SmallVectorImpl<SymbolRelation> &Relations) {
207  if (!IndexCtx.getLangOpts().CPlusPlus)
208  return;
209  const auto *CTSD =
210  dyn_cast<ClassTemplateSpecializationDecl>(D->getLexicalDeclContext());
211  if (!CTSD)
212  return;
213  llvm::PointerUnion<ClassTemplateDecl *,
215  Template = CTSD->getSpecializedTemplateOrPartial();
216  if (const auto *CTD = Template.dyn_cast<ClassTemplateDecl *>()) {
217  const CXXRecordDecl *Pattern = CTD->getTemplatedDecl();
218  bool TypeOverride = isa<TypeDecl>(D);
219  for (const NamedDecl *ND : Pattern->lookup(D->getDeclName())) {
220  if (const auto *CTD = dyn_cast<ClassTemplateDecl>(ND))
221  ND = CTD->getTemplatedDecl();
222  if (ND->isImplicit())
223  continue;
224  // Types can override other types.
225  if (!TypeOverride) {
226  if (ND->getKind() != D->getKind())
227  continue;
228  } else if (!isa<TypeDecl>(ND))
229  continue;
230  if (const auto *FD = dyn_cast<FunctionDecl>(ND)) {
231  const auto *DFD = cast<FunctionDecl>(D);
232  // Function overrides are approximated using the number of parameters.
233  if (FD->getStorageClass() != DFD->getStorageClass() ||
234  FD->getNumParams() != DFD->getNumParams())
235  continue;
236  }
237  Relations.emplace_back(
239  }
240  }
241  }
242 
243  bool VisitFunctionDecl(const FunctionDecl *D) {
244  SymbolRoleSet Roles{};
246  if (auto *CXXMD = dyn_cast<CXXMethodDecl>(D)) {
247  if (CXXMD->isVirtual())
248  Roles |= (unsigned)SymbolRole::Dynamic;
249  for (const CXXMethodDecl *O : CXXMD->overridden_methods()) {
250  Relations.emplace_back((unsigned)SymbolRole::RelationOverrideOf, O);
251  }
252  }
253  gatherTemplatePseudoOverrides(D, Relations);
254  if (const auto *Base = D->getPrimaryTemplate())
255  Relations.push_back(
257  Base->getTemplatedDecl()));
258 
259  TRY_DECL(D, IndexCtx.handleDecl(D, Roles, Relations));
260  handleDeclarator(D);
261 
262  if (const CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D)) {
263  IndexCtx.handleReference(Ctor->getParent(), Ctor->getLocation(),
264  Ctor->getParent(), Ctor->getDeclContext(),
265  (unsigned)SymbolRole::NameReference);
266 
267  // Constructor initializers.
268  for (const auto *Init : Ctor->inits()) {
269  if (Init->isWritten()) {
270  IndexCtx.indexTypeSourceInfo(Init->getTypeSourceInfo(), D);
271  if (const FieldDecl *Member = Init->getAnyMember())
272  IndexCtx.handleReference(Member, Init->getMemberLocation(), D, D,
273  (unsigned)SymbolRole::Write);
274  IndexCtx.indexBody(Init->getInit(), D, D);
275  }
276  }
277  } else if (const CXXDestructorDecl *Dtor = dyn_cast<CXXDestructorDecl>(D)) {
278  if (auto TypeNameInfo = Dtor->getNameInfo().getNamedTypeInfo()) {
279  IndexCtx.handleReference(Dtor->getParent(),
280  TypeNameInfo->getTypeLoc().getBeginLoc(),
281  Dtor->getParent(), Dtor->getDeclContext(),
282  (unsigned)SymbolRole::NameReference);
283  }
284  } else if (const auto *Guide = dyn_cast<CXXDeductionGuideDecl>(D)) {
285  IndexCtx.handleReference(Guide->getDeducedTemplate()->getTemplatedDecl(),
286  Guide->getLocation(), Guide,
287  Guide->getDeclContext());
288  }
289  // Template specialization arguments.
290  if (const ASTTemplateArgumentListInfo *TemplateArgInfo =
292  for (const auto &Arg : TemplateArgInfo->arguments())
293  handleTemplateArgumentLoc(Arg, D, D->getLexicalDeclContext());
294  }
295 
296  if (D->isThisDeclarationADefinition()) {
297  const Stmt *Body = D->getBody();
298  if (Body) {
299  IndexCtx.indexBody(Body, D, D);
300  }
301  }
302  return true;
303  }
304 
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);
311  return true;
312  }
313 
314  bool VisitDecompositionDecl(const DecompositionDecl *D) {
315  for (const auto *Binding : D->bindings())
316  TRY_DECL(Binding, IndexCtx.handleDecl(Binding));
317  return Base::VisitDecompositionDecl(D);
318  }
319 
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);
329  return true;
330  }
331 
332  bool VisitObjCIvarDecl(const ObjCIvarDecl *D) {
333  if (D->getSynthesize()) {
334  // handled in VisitObjCPropertyImplDecl
335  return true;
336  }
337  TRY_DECL(D, IndexCtx.handleDecl(D));
338  handleDeclarator(D);
339  return true;
340  }
341 
342  bool VisitMSPropertyDecl(const MSPropertyDecl *D) {
343  TRY_DECL(D, IndexCtx.handleDecl(D));
344  handleDeclarator(D);
345  return true;
346  }
347 
348  bool VisitEnumConstantDecl(const EnumConstantDecl *D) {
349  TRY_DECL(D, IndexCtx.handleDecl(D));
350  IndexCtx.indexBody(D->getInitExpr(), D);
351  return true;
352  }
353 
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);
360  }
361  return true;
362  }
363 
364  bool VisitTagDecl(const TagDecl *D) {
365  // Non-free standing tags are handled in indexTypeSourceInfo.
366  if (D->isFreeStanding()) {
367  if (D->isThisDeclarationADefinition()) {
369  gatherTemplatePseudoOverrides(D, Relations);
370  IndexCtx.indexTagDecl(D, Relations);
371  } else {
373  gatherTemplatePseudoOverrides(D, Relations);
374  return IndexCtx.handleDecl(D, D->getLocation(), SymbolRoleSet(),
375  Relations, D->getLexicalDeclContext());
376  }
377  }
378  return true;
379  }
380 
381  bool VisitEnumDecl(const EnumDecl *ED) {
382  TRY_TO(VisitTagDecl(ED));
383  // Indexing for enumdecl itself is handled inside TagDecl, we just want to
384  // visit integer-base here, which is different than other TagDecl bases.
385  if (auto *TSI = ED->getIntegerTypeSourceInfo())
386  IndexCtx.indexTypeSourceInfo(TSI, ED, ED, /*isBase=*/true);
387  return true;
388  }
389 
390  bool handleReferencedProtocols(const ObjCProtocolList &ProtList,
391  const ObjCContainerDecl *ContD,
392  SourceLocation SuperLoc) {
395  I = ProtList.begin(), E = ProtList.end(); I != E; ++I, ++LI) {
396  SourceLocation Loc = *LI;
397  ObjCProtocolDecl *PD = *I;
398  SymbolRoleSet roles{};
399  if (Loc == SuperLoc)
401  TRY_TO(IndexCtx.handleReference(PD, Loc, ContD, ContD, roles,
402  SymbolRelation{(unsigned)SymbolRole::RelationBaseOf, ContD}));
403  }
404  return true;
405  }
406 
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()) {
412  bool hasSuperTypedef = false;
413  if (auto *TInfo = D->getSuperClassTInfo()) {
414  if (auto *TT = TInfo->getType()->getAs<TypedefType>()) {
415  if (auto *TD = TT->getDecl()) {
416  hasSuperTypedef = true;
417  TRY_TO(IndexCtx.handleReference(TD, SuperLoc, D, D,
418  SymbolRoleSet()));
419  }
420  }
421  }
422  SymbolRoleSet superRoles{};
423  if (hasSuperTypedef)
424  superRoles |= (SymbolRoleSet)SymbolRole::Implicit;
425  TRY_TO(IndexCtx.handleReference(SuperD, SuperLoc, D, D, superRoles,
426  SymbolRelation{(unsigned)SymbolRole::RelationBaseOf, D}));
427  }
428  TRY_TO(handleReferencedProtocols(D->getReferencedProtocols(), D,
429  SuperLoc));
430  TRY_TO(IndexCtx.indexDeclContext(D));
431  } else {
432  return IndexCtx.handleReference(D, D->getLocation(), nullptr,
433  D->getDeclContext(), SymbolRoleSet());
434  }
435  return true;
436  }
437 
438  bool VisitObjCProtocolDecl(const ObjCProtocolDecl *D) {
439  if (D->isThisDeclarationADefinition()) {
440  TRY_DECL(D, IndexCtx.handleDecl(D));
441  TRY_TO(handleReferencedProtocols(D->getReferencedProtocols(), D,
442  /*SuperLoc=*/SourceLocation()));
443  TRY_TO(IndexCtx.indexDeclContext(D));
444  } else {
445  return IndexCtx.handleReference(D, D->getLocation(), nullptr,
446  D->getDeclContext(), SymbolRoleSet());
447  }
448  return true;
449  }
450 
451  bool VisitObjCImplementationDecl(const ObjCImplementationDecl *D) {
453  if (!Class)
454  return true;
455 
456  if (Class->isImplicitInterfaceDecl())
457  IndexCtx.handleDecl(Class);
458 
459  TRY_DECL(D, IndexCtx.handleDecl(D));
460 
461  // Visit implicit @synthesize property implementations first as their
462  // location is reported at the name of the @implementation block. This
463  // serves no purpose other than to simplify the FileCheck-based tests.
464  for (const auto *I : D->property_impls()) {
465  if (I->getLocation().isInvalid())
466  IndexCtx.indexDecl(I);
467  }
468  for (const auto *I : D->decls()) {
469  if (!isa<ObjCPropertyImplDecl>(I) ||
470  cast<ObjCPropertyImplDecl>(I)->getLocation().isValid())
471  IndexCtx.indexDecl(I);
472  }
473 
474  return true;
475  }
476 
477  bool VisitObjCCategoryDecl(const ObjCCategoryDecl *D) {
478  if (!IndexCtx.shouldIndex(D))
479  return true;
480  const ObjCInterfaceDecl *C = D->getClassInterface();
481  if (!C)
482  return true;
483  TRY_TO(IndexCtx.handleReference(C, D->getLocation(), D, D, SymbolRoleSet(),
486  }));
487  SourceLocation CategoryLoc = D->getCategoryNameLoc();
488  if (!CategoryLoc.isValid())
489  CategoryLoc = D->getLocation();
490  TRY_TO(IndexCtx.handleDecl(D, CategoryLoc));
491  TRY_TO(handleReferencedProtocols(D->getReferencedProtocols(), D,
492  /*SuperLoc=*/SourceLocation()));
493  TRY_TO(IndexCtx.indexDeclContext(D));
494  return true;
495  }
496 
497  bool VisitObjCCategoryImplDecl(const ObjCCategoryImplDecl *D) {
498  const ObjCCategoryDecl *Cat = D->getCategoryDecl();
499  if (!Cat)
500  return true;
501  const ObjCInterfaceDecl *C = D->getClassInterface();
502  if (C)
503  TRY_TO(IndexCtx.handleReference(C, D->getLocation(), D, D,
504  SymbolRoleSet()));
505  SourceLocation CategoryLoc = D->getCategoryNameLoc();
506  if (!CategoryLoc.isValid())
507  CategoryLoc = D->getLocation();
508  TRY_DECL(D, IndexCtx.handleDecl(D, CategoryLoc));
509  IndexCtx.indexDeclContext(D);
510  return true;
511  }
512 
513  bool VisitObjCMethodDecl(const ObjCMethodDecl *D) {
514  // Methods associated with a property, even user-declared ones, are
515  // handled when we handle the property.
516  if (D->isPropertyAccessor())
517  return true;
518 
519  handleObjCMethod(D);
520  return true;
521  }
522 
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);
535  return true;
536  }
537 
538  bool VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D) {
540  auto *Container = cast<ObjCImplDecl>(D->getDeclContext());
541  SourceLocation Loc = D->getLocation();
542  SymbolRoleSet Roles = 0;
544 
545  if (ObjCIvarDecl *ID = D->getPropertyIvarDecl())
546  Relations.push_back({(SymbolRoleSet)SymbolRole::RelationAccessorOf, ID});
547  if (Loc.isInvalid()) {
548  Loc = Container->getLocation();
550  }
551  TRY_DECL(D, IndexCtx.handleDecl(D, Loc, Roles, Relations));
552 
554  return true;
555 
557  SymbolRoleSet AccessorMethodRoles =
559  if (ObjCMethodDecl *MD = PD->getGetterMethodDecl()) {
560  if (MD->isPropertyAccessor() && !hasUserDefined(MD, Container))
561  IndexCtx.handleDecl(MD, Loc, AccessorMethodRoles, {}, Container);
562  }
563  if (ObjCMethodDecl *MD = PD->getSetterMethodDecl()) {
564  if (MD->isPropertyAccessor() && !hasUserDefined(MD, Container))
565  IndexCtx.handleDecl(MD, Loc, AccessorMethodRoles, {}, Container);
566  }
567  if (ObjCIvarDecl *IvarD = D->getPropertyIvarDecl()) {
568  if (IvarD->getSynthesize()) {
569  // For synthesized ivars, use the location of its name in the
570  // corresponding @synthesize. If there isn't one, use the containing
571  // @implementation's location, rather than the property's location,
572  // otherwise the header file containing the @interface will have different
573  // indexing contents based on whether the @implementation was present or
574  // not in the translation unit.
575  SymbolRoleSet IvarRoles = 0;
576  SourceLocation IvarLoc = D->getPropertyIvarDeclLoc();
577  if (D->getLocation().isInvalid()) {
578  IvarLoc = Container->getLocation();
579  IvarRoles = (SymbolRoleSet)SymbolRole::Implicit;
580  } else if (D->getLocation() == IvarLoc) {
581  IvarRoles = (SymbolRoleSet)SymbolRole::Implicit;
582  }
583  TRY_DECL(IvarD, IndexCtx.handleDecl(IvarD, IvarLoc, IvarRoles));
584  } else {
585  IndexCtx.handleReference(IvarD, D->getPropertyIvarDeclLoc(), nullptr,
586  D->getDeclContext(), SymbolRoleSet());
587  }
588  }
589  return true;
590  }
591 
592  bool VisitNamespaceDecl(const NamespaceDecl *D) {
593  TRY_DECL(D, IndexCtx.handleDecl(D));
594  IndexCtx.indexDeclContext(D);
595  return true;
596  }
597 
598  bool VisitNamespaceAliasDecl(const NamespaceAliasDecl *D) {
599  TRY_DECL(D, IndexCtx.handleDecl(D));
602  D->getLexicalDeclContext());
603  return true;
604  }
605 
606  bool VisitUsingDecl(const UsingDecl *D) {
607  IndexCtx.handleDecl(D);
608 
609  const DeclContext *DC = D->getDeclContext()->getRedeclContext();
610  const NamedDecl *Parent = dyn_cast<NamedDecl>(DC);
612  D->getLexicalDeclContext());
613  for (const auto *I : D->shadows()) {
614  // Skip unresolved using decls - we already have a decl for the using
615  // itself, so there's not much point adding another decl or reference to
616  // refer to the same location.
617  if (isa<UnresolvedUsingIfExistsDecl>(I->getUnderlyingDecl()))
618  continue;
619 
620  IndexCtx.handleReference(I->getUnderlyingDecl(), D->getLocation(), Parent,
622  }
623  return true;
624  }
625 
626  bool VisitUsingDirectiveDecl(const UsingDirectiveDecl *D) {
627  const DeclContext *DC = D->getDeclContext()->getRedeclContext();
628  const NamedDecl *Parent = dyn_cast<NamedDecl>(DC);
629 
630  // NNS for the local 'using namespace' directives is visited by the body
631  // visitor.
632  if (!D->getParentFunctionOrMethod())
634  D->getLexicalDeclContext());
635 
636  return IndexCtx.handleReference(D->getNominatedNamespaceAsWritten(),
637  D->getLocation(), Parent,
639  SymbolRoleSet());
640  }
641 
642  bool VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D) {
643  TRY_DECL(D, IndexCtx.handleDecl(D));
644  const DeclContext *DC = D->getDeclContext()->getRedeclContext();
645  const NamedDecl *Parent = dyn_cast<NamedDecl>(DC);
647  D->getLexicalDeclContext());
648  return true;
649  }
650 
651  bool VisitUnresolvedUsingTypenameDecl(const UnresolvedUsingTypenameDecl *D) {
652  TRY_DECL(D, IndexCtx.handleDecl(D));
653  const DeclContext *DC = D->getDeclContext()->getRedeclContext();
654  const NamedDecl *Parent = dyn_cast<NamedDecl>(DC);
656  D->getLexicalDeclContext());
657  return true;
658  }
659 
660  bool VisitClassTemplateSpecializationDecl(const
662  // FIXME: Notify subsequent callbacks if info comes from implicit
663  // instantiation.
664  llvm::PointerUnion<ClassTemplateDecl *,
666  Template = D->getSpecializedTemplateOrPartial();
667  const Decl *SpecializationOf =
668  Template.is<ClassTemplateDecl *>()
669  ? (Decl *)Template.get<ClassTemplateDecl *>()
670  : Template.get<ClassTemplatePartialSpecializationDecl *>();
673  IndexCtx.indexTagDecl(
675  SpecializationOf));
676  if (TypeSourceInfo *TSI = D->getTypeAsWritten())
677  IndexCtx.indexTypeSourceInfo(TSI, /*Parent=*/nullptr,
678  D->getLexicalDeclContext());
679  return true;
680  }
681 
682  static bool shouldIndexTemplateParameterDefaultValue(const NamedDecl *D) {
683  // We want to index the template parameters only once when indexing the
684  // canonical declaration.
685  if (!D)
686  return false;
687  if (const auto *FD = dyn_cast<FunctionDecl>(D))
688  return FD->getCanonicalDecl() == FD;
689  else if (const auto *TD = dyn_cast<TagDecl>(D))
690  return TD->getCanonicalDecl() == TD;
691  else if (const auto *VD = dyn_cast<VarDecl>(D))
692  return VD->getCanonicalDecl() == VD;
693  return true;
694  }
695 
696  void indexTemplateParameters(TemplateParameterList *Params,
697  const NamedDecl *Parent) {
698  for (const NamedDecl *TP : *Params) {
699  if (IndexCtx.shouldIndexTemplateParameters())
700  IndexCtx.handleDecl(TP);
701  if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(TP)) {
702  if (TTP->hasDefaultArgument())
703  IndexCtx.indexTypeSourceInfo(TTP->getDefaultArgumentInfo(), Parent);
704  if (auto *C = TTP->getTypeConstraint())
705  IndexCtx.handleReference(C->getNamedConcept(), C->getConceptNameLoc(),
706  Parent, TTP->getLexicalDeclContext());
707  } else if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(TP)) {
708  if (NTTP->hasDefaultArgument())
709  IndexCtx.indexBody(NTTP->getDefaultArgument(), Parent);
710  } else if (const auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(TP)) {
711  if (TTPD->hasDefaultArgument())
712  handleTemplateArgumentLoc(TTPD->getDefaultArgument(), Parent,
713  TP->getLexicalDeclContext());
714  }
715  }
716  if (auto *R = Params->getRequiresClause())
717  IndexCtx.indexBody(R, Parent);
718  }
719 
720  bool VisitTemplateDecl(const TemplateDecl *D) {
721  const NamedDecl *Parent = D->getTemplatedDecl();
722  if (!Parent)
723  return true;
724 
725  // Index the default values for the template parameters.
726  auto *Params = D->getTemplateParameters();
727  if (Params && shouldIndexTemplateParameterDefaultValue(Parent)) {
728  indexTemplateParameters(Params, Parent);
729  }
730 
731  return Visit(Parent);
732  }
733 
734  bool VisitConceptDecl(const ConceptDecl *D) {
735  if (auto *Params = D->getTemplateParameters())
736  indexTemplateParameters(Params, D);
737  if (auto *E = D->getConstraintExpr())
738  IndexCtx.indexBody(E, D);
739  return IndexCtx.handleDecl(D);
740  }
741 
742  bool VisitFriendDecl(const FriendDecl *D) {
743  if (auto ND = D->getFriendDecl()) {
744  // FIXME: Ignore a class template in a dependent context, these are not
745  // linked properly with their redeclarations, ending up with duplicate
746  // USRs.
747  // See comment "Friend templates are visible in fairly strange ways." in
748  // SemaTemplate.cpp which precedes code that prevents the friend template
749  // from becoming visible from the enclosing context.
750  if (isa<ClassTemplateDecl>(ND) && D->getDeclContext()->isDependentContext())
751  return true;
752  return Visit(ND);
753  }
754  if (auto Ty = D->getFriendType()) {
755  IndexCtx.indexTypeSourceInfo(Ty, cast<NamedDecl>(D->getDeclContext()));
756  }
757  return true;
758  }
759 
760  bool VisitImportDecl(const ImportDecl *D) {
761  return IndexCtx.importedModule(D);
762  }
763 
764  bool VisitStaticAssertDecl(const StaticAssertDecl *D) {
765  IndexCtx.indexBody(D->getAssertExpr(),
766  dyn_cast<NamedDecl>(D->getDeclContext()),
767  D->getLexicalDeclContext());
768  return true;
769  }
770 };
771 
772 } // anonymous namespace
773 
775  if (D->isImplicit() && shouldIgnoreIfImplicit(D))
776  return true;
777 
779  return true;
780 
781  IndexingDeclVisitor Visitor(*this);
782  bool ShouldContinue = Visitor.Visit(D);
783  if (!ShouldContinue)
784  return false;
785 
786  if (!Visitor.Handled && isa<DeclContext>(D))
787  return indexDeclContext(cast<DeclContext>(D));
788 
789  return true;
790 }
791 
793  for (const auto *I : DC->decls())
794  if (!indexDecl(I))
795  return false;
796  return true;
797 }
798 
800  if (!D || D->getLocation().isInvalid())
801  return true;
802 
803  if (isa<ObjCMethodDecl>(D))
804  return true; // Wait for the objc container.
805 
806  if (IndexOpts.ShouldTraverseDecl && !IndexOpts.ShouldTraverseDecl(D))
807  return true; // skip
808 
809  return indexDecl(D);
810 }
811 
813  for (DeclGroupRef::iterator I = DG.begin(), E = DG.end(); I != E; ++I)
814  if (!indexTopLevelDecl(*I))
815  return false;
816  return true;
817 }
clang::TemplateDecl::getTemplatedDecl
NamedDecl * getTemplatedDecl() const
Get the underlying, templated declaration.
Definition: DeclTemplate.h:440
clang::ObjCInterfaceDecl
Represents an ObjC class declaration.
Definition: DeclObjC.h:1149
clang::index::IndexingContext::shouldIndex
bool shouldIndex(const Decl *D)
Definition: IndexingContext.cpp:28
clang::UsingDirectiveDecl::getQualifierLoc
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:2962
clang::ConceptDecl::getConstraintExpr
Expr * getConstraintExpr() const
Definition: DeclTemplate.h:3277
clang::ObjCPropertyImplDecl::getPropertyIvarDecl
ObjCIvarDecl * getPropertyIvarDecl() const
Definition: DeclObjC.h:2844
clang::index::SymbolRole::RelationExtendedBy
@ RelationExtendedBy
clang::CXXConstructorDecl
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2436
IndexingContext.h
clang::DeclContext::decls
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Definition: DeclBase.h:2178
clang::UsingDirectiveDecl::getNominatedNamespaceAsWritten
NamedDecl * getNominatedNamespaceAsWritten()
Definition: DeclCXX.h:2970
clang::index::SymbolKind::Class
@ Class
clang::index::IndexingContext::indexTypeSourceInfo
void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent, const DeclContext *DC=nullptr, bool isBase=false, bool isIBType=false)
Definition: IndexTypeSourceInfo.cpp:245
clang::DecompositionDecl::bindings
ArrayRef< BindingDecl * > bindings() const
Definition: DeclCXX.h:4099
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1389
clang::Decl::hasAttr
bool hasAttr() const
Definition: DeclBase.h:560
clang::TemplateArgument::getAsTemplateOrTemplatePattern
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
Definition: TemplateBase.h:299
clang::ObjCPropertyDecl::getGetterMethodDecl
ObjCMethodDecl * getGetterMethodDecl() const
Definition: DeclObjC.h:897
clang::NamespaceAliasDecl
Represents a C++ namespace alias.
Definition: DeclCXX.h:3021
clang::ObjCImplementationDecl
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2566
clang::UsingDirectiveDecl
Represents C++ using-directive.
Definition: DeclCXX.h:2917
clang::index::IndexingContext::indexTagDecl
void indexTagDecl(const TagDecl *D, ArrayRef< SymbolRelation > Relations=None)
Definition: IndexTypeSourceInfo.cpp:304
llvm::SmallVector
Definition: LLVM.h:38
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:247
clang::EnumDecl::getIntegerTypeSourceInfo
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists,...
Definition: Decl.h:3881
Attr.h
clang::TemplateName::getAsTemplateDecl
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
Definition: TemplateName.cpp:146
clang::TypedefNameDecl::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:3325
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2930
clang::FieldDecl::getInClassInitializer
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
Definition: Decl.h:3077
clang::ParmVarDecl
Represents a parameter to a function.
Definition: Decl.h:1712
clang::ParmVarDecl::getDefaultArg
Expr * getDefaultArg()
Definition: Decl.cpp:2884
clang::ObjCCategoryDecl::getClassInterface
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.h:2339
clang::EnumConstantDecl::getInitExpr
const Expr * getInitExpr() const
Definition: Decl.h:3164
clang::index::IndexingContext::handleReference
bool handleReference(const NamedDecl *D, SourceLocation Loc, const NamedDecl *Parent, const DeclContext *DC, SymbolRoleSet Roles=SymbolRoleSet(), ArrayRef< SymbolRelation > Relations=None, const Expr *RefE=nullptr, const Decl *RefD=nullptr)
Definition: IndexingContext.cpp:74
TRY_DECL
#define TRY_DECL(D, CALL_EXPR)
Definition: IndexDecl.cpp:21
clang::FunctionDecl::getPrimaryTemplate
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
Definition: Decl.cpp:3916
clang::ObjCPropertyImplDecl
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Definition: DeclObjC.h:2771
clang::DeclGroupRef::begin
iterator begin()
Definition: DeclGroup.h:99
clang::index::IndexingContext::getLangOpts
const LangOptions & getLangOpts() const
Definition: IndexingContext.cpp:32
clang::Decl::getParentFunctionOrMethod
const DeclContext * getParentFunctionOrMethod(bool LexicalParent=false) const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext,...
Definition: DeclBase.cpp:295
clang::Decl::getAttr
T * getAttr() const
Definition: DeclBase.h:556
clang::ObjCPropertyImplDecl::getPropertyIvarDeclLoc
SourceLocation getPropertyIvarDeclLoc() const
Definition: DeclObjC.h:2847
clang::ClassTemplatePartialSpecializationDecl
Definition: DeclTemplate.h:2101
clang::DeclGroupRef::end
iterator end()
Definition: DeclGroup.h:105
clang::TemplateArgumentLocInfo::getAsExpr
Expr * getAsExpr() const
Definition: TemplateBase.h:438
clang::NamespaceAliasDecl::getAliasedNamespace
NamedDecl * getAliasedNamespace() const
Retrieve the namespace that this alias refers to, which may either be a NamespaceDecl or a NamespaceA...
Definition: DeclCXX.h:3117
clang::TemplateArgument::Expression
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
Definition: TemplateBase.h:96
clang::index::IndexingContext::shouldIndexParametersInDeclarations
bool shouldIndexParametersInDeclarations() const
Definition: IndexingContext.cpp:44
clang::ObjCImplDecl::getClassInterface
const ObjCInterfaceDecl * getClassInterface() const
Definition: DeclObjC.h:2454
clang::EnumDecl
Represents an enum.
Definition: Decl.h:3705
Decl.h
clang::TypedefType
Definition: Type.h:4535
clang::ObjCList::end
iterator end() const
Definition: DeclObjC.h:92
clang::ObjCInterfaceDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Determine whether this particular declaration of this class is actually also a definition.
Definition: DeclObjC.h:1507
clang::UnresolvedUsingTypenameDecl
Represents a dependent using declaration which was marked with typename.
Definition: DeclCXX.h:3858
clang::index::SymbolRole::RelationOverrideOf
@ RelationOverrideOf
clang::Decl::getLexicalDeclContext
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Definition: DeclBase.h:883
clang::TRY_TO
TRY_TO(TraverseType(T->getPointeeType()))
clang::index::IndexingContext::indexDeclContext
bool indexDeclContext(const DeclContext *DC)
Definition: IndexDecl.cpp:792
clang::TemplateArgumentLoc::getLocInfo
TemplateArgumentLocInfo getLocInfo() const
Definition: TemplateBase.h:510
clang::ast_matchers::attr
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
Definition: ASTMatchersInternal.cpp:1031
clang::TemplateArgument::getKind
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:244
clang::CXXMethodDecl::overridden_methods
overridden_method_range overridden_methods() const
Definition: DeclCXX.cpp:2463
DeclTemplate.h
clang::index::IndexingContext::indexDecl
bool indexDecl(const Decl *D)
Definition: IndexDecl.cpp:774
clang::ImportDecl
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:4615
clang::Decl::getKind
Kind getKind() const
Definition: DeclBase.h:435
clang::TagDecl::getQualifierLoc
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Definition: Decl.h:3668
clang::ObjCInterfaceDecl::protocol_iterator
ObjCProtocolList::iterator protocol_iterator
Definition: DeclObjC.h:1340
clang::ConceptDecl
Declaration of a C++20 concept.
Definition: DeclTemplate.h:3262
clang::FieldDecl::getBitWidth
Expr * getBitWidth() const
Definition: Decl.h:3019
clang::ObjCPropertyImplDecl::Synthesize
@ Synthesize
Definition: DeclObjC.h:2774
clang::FunctionDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
Definition: Decl.h:2205
clang::index::SymbolRole::Implicit
@ Implicit
clang::DeclaratorDecl::getQualifierLoc
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
Definition: Decl.h:824
clang::TemplateArgumentLocInfo::getAsTypeSourceInfo
TypeSourceInfo * getAsTypeSourceInfo() const
Definition: TemplateBase.h:434
clang::FriendDecl::getFriendDecl
NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
Definition: DeclFriend.h:138
clang::ObjCPropertyDecl::getSetterMethodDecl
ObjCMethodDecl * getSetterMethodDecl() const
Definition: DeclObjC.h:900
clang::DeclaratorContext::Member
@ Member
clang::DecompositionDecl
A decomposition declaration.
Definition: DeclCXX.h:4065
clang::FunctionDecl::getBody
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Definition: Decl.cpp:3116
clang::UnresolvedUsingTypenameDecl::getQualifierLoc
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3894
clang::ObjCInterfaceDecl::getReferencedProtocols
const ObjCProtocolList & getReferencedProtocols() const
Definition: DeclObjC.h:1318
clang::ObjCMethodDecl::getSelector
Selector getSelector() const
Definition: DeclObjC.h:330
clang::ObjCProtocolList
A list of Objective-C protocols, along with the source locations at which they were referenced.
Definition: DeclObjC.h:102
clang::TagDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Return true if this declaration is a completion definition of the type.
Definition: Decl.h:3523
clang::ParmVarDecl::hasUnparsedDefaultArg
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
Definition: Decl.h:1829
clang::ObjCMethodDecl::getSelectorStartLoc
SourceLocation getSelectorStartLoc() const
Definition: DeclObjC.h:291
clang::ObjCIvarDecl::getSynthesize
bool getSynthesize() const
Definition: DeclObjC.h:1977
clang::CXXDestructorDecl
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2703
clang::TemplateArgumentLoc
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:457
clang::index::IndexingContext::indexNestedNameSpecifierLoc
void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, const NamedDecl *Parent, const DeclContext *DC=nullptr)
Definition: IndexTypeSourceInfo.cpp:269
clang::BaseUsingDecl::shadows
shadow_range shadows() const
Definition: DeclCXX.h:3385
clang::FieldDecl::hasInClassInitializer
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
Definition: Decl.h:3070
clang::FriendDecl
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
Definition: DeclFriend.h:53
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:906
clang::TemplateArgumentLoc::getArgument
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:506
clang::TagDecl
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3423
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:70
clang::ObjCCategoryImplDecl
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition: DeclObjC.h:2513
clang::DeclaratorDecl::getTrailingRequiresClause
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
Definition: Decl.h:834
clang::EnumConstantDecl
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:3145
clang::ObjCMethodDecl::getReturnTypeSourceInfo
TypeSourceInfo * getReturnTypeSourceInfo() const
Definition: DeclObjC.h:346
Base
clang::UnresolvedUsingValueDecl
Represents a dependent using declaration which was not marked with typename.
Definition: DeclCXX.h:3762
ASTConcept.h
This file provides AST data structures related to concepts.
clang::index::SymbolRole::Dynamic
@ Dynamic
clang::index::SymbolRole::RelationAccessorOf
@ RelationAccessorOf
clang::ClassTemplateSpecializationDecl::getSpecializedTemplateOrPartial
llvm::PointerUnion< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > getSpecializedTemplateOrPartial() const
Retrieve the class template or class template partial specialization which was specialized by this.
Definition: DeclTemplate.h:1993
clang::Decl::isImplicit
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:576
clang::TemplateDecl::getTemplateParameters
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:427
clang::UsingDecl
Represents a C++ using-declaration.
Definition: DeclCXX.h:3414
clang::ObjCCategoryDecl
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2294
clang::ClassTemplateSpecializationDecl::getTypeAsWritten
TypeSourceInfo * getTypeAsWritten() const
Gets the type of this specialization as it was written by the user, if it was so written.
Definition: DeclTemplate.h:2051
clang::index::IndexingContext
Definition: IndexingContext.h:38
clang::TemplateArgument::TemplateExpansion
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:90
clang::StaticAssertDecl::getAssertExpr
Expr * getAssertExpr()
Definition: DeclCXX.h:3982
clang::ParmVarDecl::hasDefaultArg
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
Definition: Decl.cpp:2933
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
clang::index::IndexingContext::indexDeclGroupRef
bool indexDeclGroupRef(DeclGroupRef DG)
Definition: IndexDecl.cpp:812
clang::DeclContext::getRedeclContext
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
Definition: DeclBase.cpp:1829
clang::ObjCCategoryImplDecl::getCategoryNameLoc
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2541
clang::ObjCImplDecl::property_impls
propimpl_range property_impls() const
Definition: DeclObjC.h:2481
clang::ObjCMethodDecl::getOverriddenMethods
void getOverriddenMethods(SmallVectorImpl< const ObjCMethodDecl * > &Overridden) const
Return overridden methods for the given Method.
Definition: DeclObjC.cpp:1323
clang::index::IndexingContext::shouldIndexImplicitInstantiation
bool shouldIndexImplicitInstantiation() const
Definition: IndexingContext.cpp:40
clang::FieldDecl::isBitField
bool isBitField() const
Determines whether this field is a bitfield.
Definition: Decl.h:3008
clang::index::IndexingContext::shouldIndexFunctionLocalSymbols
bool shouldIndexFunctionLocalSymbols() const
Definition: IndexingContext.cpp:36
clang::StaticAssertDecl
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3959
clang::TagDecl::isFreeStanding
bool isFreeStanding() const
True if this tag is free standing, e.g. "struct foo;".
Definition: Decl.h:3563
clang::ClassTemplateDecl
Declaration of a class template.
Definition: DeclTemplate.h:2273
clang::ConstDeclVisitor
A simple visitor class that helps create declaration visitors.
Definition: DeclVisitor.h:73
clang::ObjCImplDecl
Definition: DeclObjC.h:2439
clang::FunctionDecl::getTemplateSpecializationArgsAsWritten
const ASTTemplateArgumentListInfo * getTemplateSpecializationArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
Definition: Decl.cpp:3942
clang::index::IndexingContext::importedModule
bool importedModule(const ImportDecl *ImportD)
Definition: IndexingContext.cpp:105
clang::TemplateDecl
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:408
clang::ObjCMethodDecl::isSynthesizedAccessorStub
bool isSynthesizedAccessorStub() const
Definition: DeclObjC.h:449
DeclVisitor.h
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
IndexDataConsumer.h
clang::DeclaratorDecl
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:758
clang::NamespaceAliasDecl::getTargetNameLoc
SourceLocation getTargetNameLoc() const
Returns the location of the identifier in the named namespace.
Definition: DeclCXX.h:3113
clang::ObjCPropertyDecl
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:732
clang::DeclGroupRef
Definition: DeclGroup.h:51
clang::UsingDecl::getQualifierLoc
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3448
clang::ObjCMethodDecl::isInstanceMethod
bool isInstanceMethod() const
Definition: DeclObjC.h:431
clang::ObjCCategoryImplDecl::getCategoryDecl
ObjCCategoryDecl * getCategoryDecl() const
Definition: DeclObjC.cpp:2176
clang::ObjCProtocolList::loc_begin
loc_iterator loc_begin() const
Definition: DeclObjC.h:112
clang::index::SymbolRole::RelationSpecializationOf
@ RelationSpecializationOf
clang::UnresolvedUsingValueDecl::getQualifierLoc
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source-location information.
Definition: DeclCXX.h:3804
clang::index::IndexingOptions::ShouldTraverseDecl
std::function< bool(const Decl *)> ShouldTraverseDecl
Definition: IndexingOptions.h:44
clang::NamespaceAliasDecl::getQualifierLoc
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name of the namespace, with source-location inf...
Definition: DeclCXX.h:3085
clang::ObjCPropertyImplDecl::Dynamic
@ Dynamic
Definition: DeclObjC.h:2775
clang::ObjCInterfaceDecl::getSuperClass
ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.cpp:352
clang::ObjCPropertyImplDecl::getPropertyImplementation
Kind getPropertyImplementation() const
Definition: DeclObjC.h:2840
clang::VarDecl::getInit
const Expr * getInit() const
Definition: Decl.h:1315
clang::index::SymbolRole::NameReference
@ NameReference
IndexSymbol.h
clang::index::SymbolRoleSet
unsigned SymbolRoleSet
Definition: IndexSymbol.h:133
clang::ObjCPropertyImplDecl::getPropertyDecl
ObjCPropertyDecl * getPropertyDecl() const
Definition: DeclObjC.h:2835
clang::ObjCMethodDecl::getBody
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
Definition: DeclObjC.cpp:872
clang::ObjCMethodDecl
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:139
clang::Builtin::ID
ID
Definition: Builtins.h:52
clang::SourceLocation::isInvalid
bool isInvalid() const
Definition: SourceLocation.h:111
clang::TemplateArgument::Type
@ Type
The template argument is a type.
Definition: TemplateBase.h:70
clang::index::IndexingContext::indexBody
void indexBody(const Stmt *S, const NamedDecl *Parent, const DeclContext *DC=nullptr)
Definition: IndexBody.cpp:495
clang
Definition: CalledOnceCheck.h:17
clang::DeclContext::lookup
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Definition: DeclBase.cpp:1693
clang::ObjCPropertyDecl::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo() const
Definition: DeclObjC.h:798
clang::ObjCInterfaceDecl::getSuperClassTInfo
TypeSourceInfo * getSuperClassTInfo() const
Definition: DeclObjC.h:1550
clang::TemplateArgument::Template
@ Template
The template argument is a template name that was provided for a template template parameter.
Definition: TemplateBase.h:86
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:71
clang::ObjCIvarDecl
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1921
clang::index::IndexingContext::isTemplateImplicitInstantiation
static bool isTemplateImplicitInstantiation(const Decl *D)
Definition: IndexingContext.cpp:149
clang::MSPropertyDecl
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:4136
clang::ParmVarDecl::hasUninstantiatedDefaultArg
bool hasUninstantiatedDefaultArg() const
Definition: Decl.h:1833
clang::ObjCProtocolDecl
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2050
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:110
clang::index::IndexingContext::indexTopLevelDecl
bool indexTopLevelDecl(const Decl *D)
Definition: IndexDecl.cpp:799
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6593
clang::NamedDecl::getDeclName
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:313
clang::DeclContext::isDependentContext
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
Definition: DeclBase.cpp:1174
clang::ObjCCategoryDecl::getReferencedProtocols
const ObjCProtocolList & getReferencedProtocols() const
Definition: DeclObjC.h:2363
unsigned
clang::TypedefNameDecl
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3275
clang::index::IndexingContext::shouldIndexTemplateParameters
bool shouldIndexTemplateParameters() const
Definition: IndexingContext.cpp:48
clang::ObjCContainerDecl
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:944
clang::ObjCCategoryDecl::getCategoryNameLoc
SourceLocation getCategoryNameLoc() const
Definition: DeclObjC.h:2427
clang::ObjCMethodDecl::isPropertyAccessor
bool isPropertyAccessor() const
Definition: DeclObjC.h:441
clang::ObjCMethodDecl::parameters
ArrayRef< ParmVarDecl * > parameters() const
Definition: DeclObjC.h:376
clang::index::SymbolRole::Write
@ Write
Parent
NodeId Parent
Definition: ASTDiff.cpp:190
clang::ObjCInterfaceDecl::getSuperClassLoc
SourceLocation getSuperClassLoc() const
Retrieve the starting location of the superclass.
Definition: DeclObjC.cpp:372
clang::ASTTemplateArgumentListInfo
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:612
llvm::SmallVectorImpl
Definition: Randstruct.h:18
clang::TemplateArgumentLoc::getTemplateQualifierLoc
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Definition: TemplateBase.h:540
clang::index::IndexingContext::handleDecl
bool handleDecl(const Decl *D, SymbolRoleSet Roles=SymbolRoleSet(), ArrayRef< SymbolRelation > Relations=None)
Definition: IndexingContext.cpp:52
clang::TemplateArgumentLoc::getTemplateNameLoc
SourceLocation getTemplateNameLoc() const
Definition: TemplateBase.h:547
clang::ObjCProtocolDecl::getReferencedProtocols
const ObjCProtocolList & getReferencedProtocols() const
Definition: DeclObjC.h:2118
clang::ClassTemplateSpecializationDecl
Represents a class template specialization, which refers to a class template with a given set of temp...
Definition: DeclTemplate.h:1829
clang::ObjCMethodDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Returns whether this specific method is a definition.
Definition: DeclObjC.h:538
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:432
clang::NamespaceDecl
Represent a C++ namespace.
Definition: Decl.h:542
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1904
clang::ObjCProtocolDecl::isThisDeclarationADefinition
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
Definition: DeclObjC.h:2226
clang::TemplateArgumentLocInfo
Location information for a TemplateArgument.
Definition: TemplateBase.h:405
clang::index::SymbolRelation
Represents a relation to another symbol for a symbol occurrence.
Definition: IndexSymbol.h:136
clang::DeclaratorDecl::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:787
clang::ObjCList::begin
iterator begin() const
Definition: DeclObjC.h:91
clang::TypedefNameDecl::isTransparentTag
bool isTransparentTag() const
Determines if this typedef shares a name and spelling location with its underlying tag type,...
Definition: Decl.h:3359
clang::FriendDecl::getFriendType
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Definition: DeclFriend.h:123
clang::ObjCMethodDecl::param_size
unsigned param_size() const
Definition: DeclObjC.h:350
clang::CXXMethodDecl
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1983
clang::Decl::getDeclContext
DeclContext * getDeclContext()
Definition: DeclBase.h:441