clang  14.0.0git
IndexingContext.cpp
Go to the documentation of this file.
1 //===- IndexingContext.cpp - Indexing context data ------------------------===//
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/ASTContext.h"
11 #include "clang/AST/Attr.h"
12 #include "clang/AST/DeclObjC.h"
13 #include "clang/AST/DeclTemplate.h"
17 
18 using namespace clang;
19 using namespace index;
20 
21 static bool isGeneratedDecl(const Decl *D) {
22  if (auto *attr = D->getAttr<ExternalSourceSymbolAttr>()) {
23  return attr->getGeneratedDeclaration();
24  }
25  return false;
26 }
27 
29  return !isGeneratedDecl(D);
30 }
31 
33  return Ctx->getLangOpts();
34 }
35 
37  return IndexOpts.IndexFunctionLocals;
38 }
39 
41  return IndexOpts.IndexImplicitInstantiation;
42 }
43 
45  return IndexOpts.IndexParametersInDeclarations;
46 }
47 
49  return IndexOpts.IndexTemplateParameters;
50 }
51 
53  SymbolRoleSet Roles,
54  ArrayRef<SymbolRelation> Relations) {
55  return handleDecl(D, D->getLocation(), Roles, Relations);
56 }
57 
59  SymbolRoleSet Roles,
60  ArrayRef<SymbolRelation> Relations,
61  const DeclContext *DC) {
62  if (!DC)
63  DC = D->getDeclContext();
64 
65  const Decl *OrigD = D;
66  if (isa<ObjCPropertyImplDecl>(D)) {
67  D = cast<ObjCPropertyImplDecl>(D)->getPropertyDecl();
68  }
69  return handleDeclOccurrence(D, Loc, /*IsRef=*/false, cast<Decl>(DC),
70  Roles, Relations,
71  nullptr, OrigD, DC);
72 }
73 
75  const NamedDecl *Parent,
76  const DeclContext *DC,
77  SymbolRoleSet Roles,
78  ArrayRef<SymbolRelation> Relations,
79  const Expr *RefE,
80  const Decl *RefD) {
82  return true;
83 
85  (isa<NonTypeTemplateParmDecl>(D) || isa<TemplateTypeParmDecl>(D) ||
86  isa<TemplateTemplateParmDecl>(D))) {
87  return true;
88  }
89 
90  return handleDeclOccurrence(D, Loc, /*IsRef=*/true, Parent, Roles, Relations,
91  RefE, RefD, DC);
92 }
93 
94 static void reportModuleReferences(const Module *Mod,
96  const ImportDecl *ImportD,
97  IndexDataConsumer &DataConsumer) {
98  if (!Mod)
99  return;
100  reportModuleReferences(Mod->Parent, IdLocs.drop_back(), ImportD,
101  DataConsumer);
102  DataConsumer.handleModuleOccurrence(
103  ImportD, Mod, (SymbolRoleSet)SymbolRole::Reference, IdLocs.back());
104 }
105 
107  if (ImportD->isInvalidDecl())
108  return true;
109 
110  SourceLocation Loc;
111  auto IdLocs = ImportD->getIdentifierLocs();
112  if (!IdLocs.empty())
113  Loc = IdLocs.back();
114  else
115  Loc = ImportD->getLocation();
116 
118  FileID FID = SM.getFileID(SM.getFileLoc(Loc));
119  if (FID.isInvalid())
120  return true;
121 
122  bool Invalid = false;
123  const SrcMgr::SLocEntry &SEntry = SM.getSLocEntry(FID, &Invalid);
124  if (Invalid || !SEntry.isFile())
125  return true;
126 
127  if (SEntry.getFile().getFileCharacteristic() != SrcMgr::C_User) {
128  switch (IndexOpts.SystemSymbolFilter) {
130  return true;
133  break;
134  }
135  }
136 
137  const Module *Mod = ImportD->getImportedModule();
138  if (!ImportD->isImplicit() && Mod->Parent && !IdLocs.empty()) {
139  reportModuleReferences(Mod->Parent, IdLocs.drop_back(), ImportD,
140  DataConsumer);
141  }
142 
144  if (ImportD->isImplicit())
145  Roles |= (unsigned)SymbolRole::Implicit;
146 
147  return DataConsumer.handleModuleOccurrence(ImportD, Mod, Roles, Loc);
148 }
149 
153  SD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
154  TKind = SD->getSpecializationKind();
155  } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
156  TKind = FD->getTemplateSpecializationKind();
157  } else if (auto *VD = dyn_cast<VarDecl>(D)) {
158  TKind = VD->getTemplateSpecializationKind();
159  } else if (const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
160  if (RD->getInstantiatedFromMemberClass())
161  TKind = RD->getTemplateSpecializationKind();
162  } else if (const auto *ED = dyn_cast<EnumDecl>(D)) {
163  if (ED->getInstantiatedFromMemberEnum())
164  TKind = ED->getTemplateSpecializationKind();
165  } else if (isa<FieldDecl>(D) || isa<TypedefNameDecl>(D) ||
166  isa<EnumConstantDecl>(D)) {
167  if (const auto *Parent = dyn_cast<Decl>(D->getDeclContext()))
169  }
170  switch (TKind) {
171  case TSK_Undeclared:
172  // Instantiation maybe not happen yet when we see a SpecializationDecl,
173  // e.g. when the type doesn't need to be complete, we still treat it as an
174  // instantiation as we'd like to keep the canonicalized result consistent.
175  return isa<ClassTemplateSpecializationDecl>(D);
177  return false;
181  return true;
182  }
183  llvm_unreachable("invalid TemplateSpecializationKind");
184 }
185 
186 bool IndexingContext::shouldIgnoreIfImplicit(const Decl *D) {
187  if (isa<ObjCInterfaceDecl>(D))
188  return false;
189  if (isa<ObjCCategoryDecl>(D))
190  return false;
191  if (isa<ObjCIvarDecl>(D))
192  return false;
193  if (isa<ObjCMethodDecl>(D))
194  return false;
195  if (isa<ImportDecl>(D))
196  return false;
197  return true;
198 }
199 
200 static const CXXRecordDecl *
202  if (const auto *CTSD =
203  dyn_cast<ClassTemplateSpecializationDecl>(D->getDeclContext()))
204  return CTSD->getTemplateInstantiationPattern();
205  else if (const auto *RD = dyn_cast<CXXRecordDecl>(D->getDeclContext()))
206  return RD->getInstantiatedFromMemberClass();
207  return nullptr;
208 }
209 
212  SD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
213  const auto *Template = SD->getTemplateInstantiationPattern();
214  if (Template)
215  return Template;
216  // Fallback to primary template if no instantiation is available yet (e.g.
217  // the type doesn't need to be complete).
218  return SD->getSpecializedTemplate()->getTemplatedDecl();
219  } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
220  return FD->getTemplateInstantiationPattern();
221  } else if (auto *VD = dyn_cast<VarDecl>(D)) {
222  return VD->getTemplateInstantiationPattern();
223  } else if (const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
224  return RD->getInstantiatedFromMemberClass();
225  } else if (const auto *ED = dyn_cast<EnumDecl>(D)) {
226  return ED->getInstantiatedFromMemberEnum();
227  } else if (isa<FieldDecl>(D) || isa<TypedefNameDecl>(D)) {
228  const auto *ND = cast<NamedDecl>(D);
229  if (const CXXRecordDecl *Pattern =
231  for (const NamedDecl *BaseND : Pattern->lookup(ND->getDeclName())) {
232  if (BaseND->isImplicit())
233  continue;
234  if (BaseND->getKind() == ND->getKind())
235  return BaseND;
236  }
237  }
238  } else if (const auto *ECD = dyn_cast<EnumConstantDecl>(D)) {
239  if (const auto *ED = dyn_cast<EnumDecl>(ECD->getDeclContext())) {
240  if (const EnumDecl *Pattern = ED->getInstantiatedFromMemberEnum()) {
241  for (const NamedDecl *BaseECD : Pattern->lookup(ECD->getDeclName()))
242  return BaseECD;
243  }
244  }
245  }
246  return nullptr;
247 }
248 
249 static bool isDeclADefinition(const Decl *D, const DeclContext *ContainerDC, ASTContext &Ctx) {
250  if (auto VD = dyn_cast<VarDecl>(D))
251  return VD->isThisDeclarationADefinition(Ctx);
252 
253  if (auto FD = dyn_cast<FunctionDecl>(D))
254  return FD->isThisDeclarationADefinition();
255 
256  if (auto TD = dyn_cast<TagDecl>(D))
257  return TD->isThisDeclarationADefinition();
258 
259  if (auto MD = dyn_cast<ObjCMethodDecl>(D))
260  return MD->isThisDeclarationADefinition() || isa<ObjCImplDecl>(ContainerDC);
261 
262  if (isa<TypedefNameDecl>(D) ||
263  isa<EnumConstantDecl>(D) ||
264  isa<FieldDecl>(D) ||
265  isa<MSPropertyDecl>(D) ||
266  isa<ObjCImplDecl>(D) ||
267  isa<ObjCPropertyImplDecl>(D))
268  return true;
269 
270  return false;
271 }
272 
273 /// Whether the given NamedDecl should be skipped because it has no name.
274 static bool shouldSkipNamelessDecl(const NamedDecl *ND) {
275  return (ND->getDeclName().isEmpty() && !isa<TagDecl>(ND) &&
276  !isa<ObjCCategoryDecl>(ND)) || isa<CXXDeductionGuideDecl>(ND);
277 }
278 
279 static const Decl *adjustParent(const Decl *Parent) {
280  if (!Parent)
281  return nullptr;
282  for (;; Parent = cast<Decl>(Parent->getDeclContext())) {
283  if (isa<TranslationUnitDecl>(Parent))
284  return nullptr;
285  if (isa<LinkageSpecDecl>(Parent) || isa<BlockDecl>(Parent))
286  continue;
287  if (auto NS = dyn_cast<NamespaceDecl>(Parent)) {
288  if (NS->isAnonymousNamespace())
289  continue;
290  } else if (auto RD = dyn_cast<RecordDecl>(Parent)) {
291  if (RD->isAnonymousStructOrUnion())
292  continue;
293  } else if (auto ND = dyn_cast<NamedDecl>(Parent)) {
294  if (shouldSkipNamelessDecl(ND))
295  continue;
296  }
297  return Parent;
298  }
299 }
300 
301 static const Decl *getCanonicalDecl(const Decl *D) {
302  D = D->getCanonicalDecl();
303  if (auto TD = dyn_cast<TemplateDecl>(D)) {
304  if (auto TTD = TD->getTemplatedDecl()) {
305  D = TTD;
306  assert(D->isCanonicalDecl());
307  }
308  }
309 
310  return D;
311 }
312 
314  bool IsRef, SymbolRoleSet Roles, ArrayRef<SymbolRelation> Relations) {
315  if (!IsRef)
316  return true;
317 
318  auto acceptForRelation = [](SymbolRoleSet roles) -> bool {
319  bool accept = false;
320  applyForEachSymbolRoleInterruptible(roles, [&accept](SymbolRole r) -> bool {
321  switch (r) {
328  accept = true;
329  return false;
333  case SymbolRole::Read:
334  case SymbolRole::Write:
335  case SymbolRole::Call:
336  case SymbolRole::Dynamic:
345  return true;
346  }
347  llvm_unreachable("Unsupported SymbolRole value!");
348  });
349  return accept;
350  };
351 
352  for (auto &Rel : Relations) {
353  if (acceptForRelation(Rel.Roles))
354  return true;
355  }
356 
357  return false;
358 }
359 
360 bool IndexingContext::handleDeclOccurrence(const Decl *D, SourceLocation Loc,
361  bool IsRef, const Decl *Parent,
362  SymbolRoleSet Roles,
363  ArrayRef<SymbolRelation> Relations,
364  const Expr *OrigE,
365  const Decl *OrigD,
366  const DeclContext *ContainerDC) {
367  if (D->isImplicit() && !isa<ObjCMethodDecl>(D))
368  return true;
369  if (!isa<NamedDecl>(D) || shouldSkipNamelessDecl(cast<NamedDecl>(D)))
370  return true;
371 
373  FileID FID = SM.getFileID(SM.getFileLoc(Loc));
374  if (FID.isInvalid())
375  return true;
376 
377  bool Invalid = false;
378  const SrcMgr::SLocEntry &SEntry = SM.getSLocEntry(FID, &Invalid);
379  if (Invalid || !SEntry.isFile())
380  return true;
381 
382  if (SEntry.getFile().getFileCharacteristic() != SrcMgr::C_User) {
383  switch (IndexOpts.SystemSymbolFilter) {
385  return true;
387  if (!shouldReportOccurrenceForSystemDeclOnlyMode(IsRef, Roles, Relations))
388  return true;
389  break;
391  break;
392  }
393  }
394 
395  if (!OrigD)
396  OrigD = D;
397 
399  if (!IsRef)
400  return true;
402  if (!D)
403  return true;
405  }
406 
407  if (IsRef)
409  else if (isDeclADefinition(OrigD, ContainerDC, *Ctx))
410  Roles |= (unsigned)SymbolRole::Definition;
411  else
413 
414  D = getCanonicalDecl(D);
416  if (Parent)
418 
419  SmallVector<SymbolRelation, 6> FinalRelations;
420  FinalRelations.reserve(Relations.size()+1);
421 
422  auto addRelation = [&](SymbolRelation Rel) {
423  auto It = llvm::find_if(FinalRelations, [&](SymbolRelation Elem) -> bool {
424  return Elem.RelatedSymbol == Rel.RelatedSymbol;
425  });
426  if (It != FinalRelations.end()) {
427  It->Roles |= Rel.Roles;
428  } else {
429  FinalRelations.push_back(Rel);
430  }
431  Roles |= Rel.Roles;
432  };
433 
434  if (Parent) {
435  if (IsRef || (!isa<ParmVarDecl>(D) && isFunctionLocalSymbol(D))) {
436  addRelation(SymbolRelation{
438  Parent
439  });
440  } else {
441  addRelation(SymbolRelation{
443  Parent
444  });
445  }
446  }
447 
448  for (auto &Rel : Relations) {
449  addRelation(SymbolRelation(Rel.Roles,
450  Rel.RelatedSymbol->getCanonicalDecl()));
451  }
452 
453  IndexDataConsumer::ASTNodeInfo Node{OrigE, OrigD, Parent, ContainerDC};
454  return DataConsumer.handleDeclOccurrence(D, Roles, FinalRelations, Loc, Node);
455 }
456 
458  SourceLocation Loc,
459  const MacroInfo &MI) {
460  if (!shouldIndexMacroOccurrence(/*IsRef=*/false, Loc))
461  return;
463  DataConsumer.handleMacroOccurrence(&Name, &MI, Roles, Loc);
464 }
465 
467  SourceLocation Loc,
468  const MacroInfo &MI) {
469  if (!shouldIndexMacroOccurrence(/*IsRef=*/false, Loc))
470  return;
472  DataConsumer.handleMacroOccurrence(&Name, &MI, Roles, Loc);
473 }
474 
476  SourceLocation Loc,
477  const MacroInfo &MI) {
478  if (!shouldIndexMacroOccurrence(/*IsRef=*/true, Loc))
479  return;
481  DataConsumer.handleMacroOccurrence(&Name, &MI, Roles, Loc);
482 }
483 
484 bool IndexingContext::shouldIndexMacroOccurrence(bool IsRef,
485  SourceLocation Loc) {
486  if (!IndexOpts.IndexMacros)
487  return false;
488 
489  switch (IndexOpts.SystemSymbolFilter) {
491  break;
493  if (!IsRef)
494  return true;
495  break;
497  return true;
498  }
499 
501  FileID FID = SM.getFileID(SM.getFileLoc(Loc));
502  if (FID.isInvalid())
503  return false;
504 
505  bool Invalid = false;
506  const SrcMgr::SLocEntry &SEntry = SM.getSLocEntry(FID, &Invalid);
507  if (Invalid || !SEntry.isFile())
508  return false;
509 
510  return SEntry.getFile().getFileCharacteristic() == SrcMgr::C_User;
511 }
clang::index::SymbolRole::AddressOf
@ AddressOf
clang::index::IndexingContext::shouldIndex
bool shouldIndex(const Decl *D)
Definition: IndexingContext.cpp:28
shouldSkipNamelessDecl
static bool shouldSkipNamelessDecl(const NamedDecl *ND)
Whether the given NamedDecl should be skipped because it has no name.
Definition: IndexingContext.cpp:274
clang::index::applyForEachSymbolRoleInterruptible
bool applyForEachSymbolRoleInterruptible(SymbolRoleSet Roles, llvm::function_ref< bool(SymbolRole)> Fn)
Definition: IndexSymbol.cpp:412
clang::index::IndexingOptions::IndexMacros
bool IndexMacros
Definition: IndexingOptions.h:31
clang::index::SymbolRole::RelationExtendedBy
@ RelationExtendedBy
IndexingContext.h
clang::index::IndexDataConsumer::ASTNodeInfo
Definition: IndexDataConsumer.h:28
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1347
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:249
clang::index::SymbolRole::RelationChildOf
@ RelationChildOf
clang::TSK_Undeclared
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
Definition: Specifiers.h:176
Attr.h
clang::index::SymbolRole::Definition
@ Definition
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
clang::index::IndexDataConsumer
Definition: IndexDataConsumer.h:26
clang::index::IndexingContext::getLangOpts
const LangOptions & getLangOpts() const
Definition: IndexingContext.cpp:32
clang::MacroInfo
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:39
SourceManager.h
clang::index::IndexingOptions::IndexParametersInDeclarations
bool IndexParametersInDeclarations
Definition: IndexingOptions.h:37
clang::index::SymbolRole::Reference
@ Reference
clang::index::IndexingOptions::SystemSymbolFilterKind::DeclarationsOnly
@ DeclarationsOnly
clang::Decl::getAttr
T * getAttr() const
Definition: DeclBase.h:543
clang::index::SymbolRole::Call
@ Call
getDeclContextForTemplateInstationPattern
static const CXXRecordDecl * getDeclContextForTemplateInstationPattern(const Decl *D)
Definition: IndexingContext.cpp:201
clang::ASTContext::getSourceManager
SourceManager & getSourceManager()
Definition: ASTContext.h:695
clang::index::IndexingContext::shouldIndexParametersInDeclarations
bool shouldIndexParametersInDeclarations() const
Definition: IndexingContext.cpp:44
clang::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:626
clang::EnumDecl
Represents an enum.
Definition: Decl.h:3595
clang::driver::tools::arm::ReadTPMode::Invalid
@ Invalid
DeclObjC.h
clang::index::SymbolRole::RelationOverrideOf
@ RelationOverrideOf
clang::CXXRecordDecl::getInstantiatedFromMemberClass
CXXRecordDecl * getInstantiatedFromMemberClass() const
If this record is an instantiation of a member class, retrieves the member class from which it was in...
Definition: DeclCXX.cpp:1790
clang::TSK_ExplicitInstantiationDeclaration
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
Definition: Specifiers.h:187
clang::ast_matchers::attr
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
Definition: ASTMatchersInternal.cpp:1030
clang::Module
Describes a module or submodule.
Definition: Module.h:96
DeclTemplate.h
clang::index::SymbolRole::Declaration
@ Declaration
clang::ImportDecl
Describes a module import declaration, which makes the contents of the named module visible in the cu...
Definition: Decl.h:4456
Node
DynTypedNode Node
Definition: ASTMatchFinder.cpp:67
clang::index::IndexDataConsumer::handleModuleOccurrence
virtual bool handleModuleOccurrence(const ImportDecl *ImportD, const Module *Mod, SymbolRoleSet Roles, SourceLocation Loc)
Definition: IndexDataConsumer.h:60
clang::index::IndexingContext::handleMacroUndefined
void handleMacroUndefined(const IdentifierInfo &Name, SourceLocation Loc, const MacroInfo &MI)
Definition: IndexingContext.cpp:466
clang::index::IndexingOptions::IndexTemplateParameters
bool IndexTemplateParameters
Definition: IndexingOptions.h:38
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:212
clang::index::SymbolRole::Implicit
@ Implicit
clang::index::SymbolRole::RelationReceivedBy
@ RelationReceivedBy
clang::SrcMgr::SLocEntry::getFile
const FileInfo & getFile() const
Definition: SourceManager.h:484
clang::index::IndexingContext::handleMacroDefined
void handleMacroDefined(const IdentifierInfo &Name, SourceLocation Loc, const MacroInfo &MI)
Definition: IndexingContext.cpp:457
clang::Decl::isInvalidDecl
bool isInvalidDecl() const
Definition: DeclBase.h:558
clang::index::IndexingOptions::SystemSymbolFilterKind::All
@ All
clang::Decl::getCanonicalDecl
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:901
clang::index::IndexingContext::handleMacroReference
void handleMacroReference(const IdentifierInfo &Name, SourceLocation Loc, const MacroInfo &MD)
Definition: IndexingContext.cpp:475
clang::index::SymbolRole::RelationIBTypeOf
@ RelationIBTypeOf
ASTContext.h
reportModuleReferences
static void reportModuleReferences(const Module *Mod, ArrayRef< SourceLocation > IdLocs, const ImportDecl *ImportD, IndexDataConsumer &DataConsumer)
Definition: IndexingContext.cpp:94
clang::SrcMgr::FileInfo::getFileCharacteristic
CharacteristicKind getFileCharacteristic() const
Return whether this is a system header or not.
Definition: SourceManager.h:328
clang::TSK_ExplicitInstantiationDefinition
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
Definition: Specifiers.h:191
clang::ImportDecl::getIdentifierLocs
ArrayRef< SourceLocation > getIdentifierLocs() const
Retrieves the locations of each of the identifiers that make up the complete module name in the impor...
Definition: Decl.cpp:5161
clang::SrcMgr::C_User
@ C_User
Definition: SourceManager.h:79
clang::index::IndexDataConsumer::handleMacroOccurrence
virtual bool handleMacroOccurrence(const IdentifierInfo *Name, const MacroInfo *MI, SymbolRoleSet Roles, SourceLocation Loc)
Definition: IndexDataConsumer.h:49
clang::index::isFunctionLocalSymbol
bool isFunctionLocalSymbol(const Decl *D)
Definition: IndexSymbol.cpp:53
clang::index::SymbolRole::Dynamic
@ Dynamic
clang::index::SymbolRelation::RelatedSymbol
const Decl * RelatedSymbol
Definition: IndexSymbol.h:136
clang::index::SymbolRole::Undefinition
@ Undefinition
clang::index::SymbolRole::RelationAccessorOf
@ RelationAccessorOf
clang::Decl::isImplicit
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:563
clang::index::SymbolRole::RelationCalledBy
@ RelationCalledBy
clang::Module::Parent
Module * Parent
The parent of this module.
Definition: Module.h:124
adjustTemplateImplicitInstantiation
static const Decl * adjustTemplateImplicitInstantiation(const Decl *D)
Definition: IndexingContext.cpp:210
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:255
clang::EnumDecl::getInstantiatedFromMemberEnum
EnumDecl * getInstantiatedFromMemberEnum() const
Returns the enumeration (declared within the template) from which this enumeration type was instantia...
Definition: Decl.cpp:4508
SourceLocation.h
clang::TemplateSpecializationKind
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:173
clang::index::IndexingContext::shouldIndexImplicitInstantiation
bool shouldIndexImplicitInstantiation() const
Definition: IndexingContext.cpp:40
clang::index::IndexingContext::shouldIndexFunctionLocalSymbols
bool shouldIndexFunctionLocalSymbols() const
Definition: IndexingContext.cpp:36
getCanonicalDecl
static const Decl * getCanonicalDecl(const Decl *D)
Definition: IndexingContext.cpp:301
clang::index::IndexingOptions::IndexFunctionLocals
bool IndexFunctionLocals
Definition: IndexingOptions.h:29
clang::index::IndexingContext::importedModule
bool importedModule(const ImportDecl *ImportD)
Definition: IndexingContext.cpp:106
clang::index::SymbolRole
SymbolRole
Set of roles that are attributed to symbol occurrences.
Definition: IndexSymbol.h:100
llvm::ArrayRef
Definition: LLVM.h:34
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89
IndexDataConsumer.h
isGeneratedDecl
static bool isGeneratedDecl(const Decl *D)
Definition: IndexingContext.cpp:21
clang::index::IndexingOptions::SystemSymbolFilterKind::None
@ None
clang::index::SymbolRole::Read
@ Read
clang::index::SymbolRole::RelationSpecializationOf
@ RelationSpecializationOf
clang::index::IndexingOptions::SystemSymbolFilter
SystemSymbolFilterKind SystemSymbolFilter
Definition: IndexingOptions.h:27
clang::TSK_ExplicitSpecialization
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
Definition: Specifiers.h:183
clang::index::SymbolRole::NameReference
@ NameReference
clang::index::IndexingOptions::IndexImplicitInstantiation
bool IndexImplicitInstantiation
Definition: IndexingOptions.h:30
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:84
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:58
shouldReportOccurrenceForSystemDeclOnlyMode
static bool shouldReportOccurrenceForSystemDeclOnlyMode(bool IsRef, SymbolRoleSet Roles, ArrayRef< SymbolRelation > Relations)
Definition: IndexingContext.cpp:313
clang::index::IndexDataConsumer::handleDeclOccurrence
virtual bool handleDeclOccurrence(const Decl *D, SymbolRoleSet Roles, ArrayRef< SymbolRelation > Relations, SourceLocation Loc, ASTNodeInfo ASTNode)
Definition: IndexDataConsumer.h:42
clang
Definition: CalledOnceCheck.h:17
isDeclADefinition
static bool isDeclADefinition(const Decl *D, const DeclContext *ContainerDC, ASTContext &Ctx)
Definition: IndexingContext.cpp:249
clang::index::IndexingContext::isTemplateImplicitInstantiation
static bool isTemplateImplicitInstantiation(const Decl *D)
Definition: IndexingContext.cpp:150
clang::FileID
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Definition: SourceLocation.h:38
clang::FileID::isInvalid
bool isInvalid() const
Definition: SourceLocation.h:45
clang::NamedDecl::getDeclName
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:313
unsigned
clang::index::IndexingContext::shouldIndexTemplateParameters
bool shouldIndexTemplateParameters() const
Definition: IndexingContext.cpp:48
clang::index::SymbolRole::Write
@ Write
Parent
NodeId Parent
Definition: ASTDiff.cpp:192
adjustParent
static const Decl * adjustParent(const Decl *Parent)
Definition: IndexingContext.cpp:279
clang::index::SymbolRole::RelationContainedBy
@ RelationContainedBy
clang::DeclarationName::isEmpty
bool isEmpty() const
Evaluates true when this declaration name is empty.
Definition: DeclarationName.h:372
clang::ImportDecl::getImportedModule
Module * getImportedModule() const
Retrieve the module that was imported by the import declaration.
Definition: Decl.h:4515
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::index::IndexingContext::handleDecl
bool handleDecl(const Decl *D, SymbolRoleSet Roles=SymbolRoleSet(), ArrayRef< SymbolRelation > Relations=None)
Definition: IndexingContext.cpp:52
SM
#define SM(sm)
Definition: Cuda.cpp:81
clang::TSK_ImplicitInstantiation
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
Definition: Specifiers.h:179
clang::SrcMgr::SLocEntry::isFile
bool isFile() const
Definition: SourceManager.h:482
clang::ClassTemplateSpecializationDecl
Represents a class template specialization, which refers to a class template with a given set of temp...
Definition: DeclTemplate.h:1804
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:430
clang::CXXRecordDecl::getTemplateInstantiationPattern
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
Definition: DeclCXX.cpp:1844
clang::Decl::isCanonicalDecl
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
Definition: DeclBase.h:907
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1857
clang::index::SymbolRelation
Represents a relation to another symbol for a symbol occurrence.
Definition: IndexSymbol.h:134
clang::ASTContext::getLangOpts
const LangOptions & getLangOpts() const
Definition: ASTContext.h:765
clang::index::SymbolRole::RelationBaseOf
@ RelationBaseOf
clang::SrcMgr::SLocEntry
This is a discriminated union of FileInfo and ExpansionInfo.
Definition: SourceManager.h:467
clang::Decl::getDeclContext
DeclContext * getDeclContext()
Definition: DeclBase.h:439