clang 18.0.0git
IndexSymbol.cpp
Go to the documentation of this file.
1//===--- IndexSymbol.cpp - Types and functions for indexing symbols -------===//
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
10#include "clang/AST/Attr.h"
11#include "clang/AST/DeclCXX.h"
12#include "clang/AST/DeclObjC.h"
15#include "clang/Lex/MacroInfo.h"
16
17using namespace clang;
18using namespace clang::index;
19
20/// \returns true if \c D is a subclass of 'XCTestCase'.
21static bool isUnitTestCase(const ObjCInterfaceDecl *D) {
22 if (!D)
23 return false;
24 while (const ObjCInterfaceDecl *SuperD = D->getSuperClass()) {
25 if (SuperD->getName() == "XCTestCase")
26 return true;
27 D = SuperD;
28 }
29 return false;
30}
31
32/// \returns true if \c D is in a subclass of 'XCTestCase', returns void, has
33/// no parameters, and its name starts with 'test'.
34static bool isUnitTest(const ObjCMethodDecl *D) {
35 if (!D->parameters().empty())
36 return false;
37 if (!D->getReturnType()->isVoidType())
38 return false;
39 if (!D->getSelector().getNameForSlot(0).startswith("test"))
40 return false;
42}
43
44static void checkForIBOutlets(const Decl *D, SymbolPropertySet &PropSet) {
45 if (D->hasAttr<IBOutletAttr>()) {
46 PropSet |= (SymbolPropertySet)SymbolProperty::IBAnnotated;
47 } else if (D->hasAttr<IBOutletCollectionAttr>()) {
48 PropSet |= (SymbolPropertySet)SymbolProperty::IBAnnotated;
49 PropSet |= (SymbolPropertySet)SymbolProperty::IBOutletCollection;
50 }
51}
52
54 assert(D);
55
56 if (isa<ParmVarDecl>(D))
57 return true;
58
59 if (isa<ObjCTypeParamDecl>(D))
60 return true;
61
62 if (isa<UsingDirectiveDecl>(D))
63 return false;
65 return false;
66
67 if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
68 switch (ND->getFormalLinkage()) {
69 case NoLinkage:
70 case InternalLinkage:
71 return true;
74 llvm_unreachable("Not a sema linkage");
75 case ModuleLinkage:
76 case ExternalLinkage:
77 return false;
78 }
79 }
80
81 return true;
82}
83
85 assert(D);
86 SymbolInfo Info;
87 Info.Kind = SymbolKind::Unknown;
88 Info.SubKind = SymbolSubKind::None;
90 Info.Lang = SymbolLanguage::C;
91
92 if (isFunctionLocalSymbol(D)) {
93 Info.Properties |= (SymbolPropertySet)SymbolProperty::Local;
94 }
95 if (isa<ObjCProtocolDecl>(D->getDeclContext())) {
96 Info.Properties |= (SymbolPropertySet)SymbolProperty::ProtocolInterface;
97 }
98
99 if (auto *VT = dyn_cast<VarTemplateDecl>(D)) {
100 Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
101 Info.Lang = SymbolLanguage::CXX;
102 // All other fields are filled from the templated decl.
103 D = VT->getTemplatedDecl();
104 }
105
106 if (const TagDecl *TD = dyn_cast<TagDecl>(D)) {
107 switch (TD->getTagKind()) {
108 case TTK_Struct:
109 Info.Kind = SymbolKind::Struct; break;
110 case TTK_Union:
111 Info.Kind = SymbolKind::Union; break;
112 case TTK_Class:
113 Info.Kind = SymbolKind::Class;
114 Info.Lang = SymbolLanguage::CXX;
115 break;
116 case TTK_Interface:
117 Info.Kind = SymbolKind::Protocol;
118 Info.Lang = SymbolLanguage::CXX;
119 break;
120 case TTK_Enum:
121 Info.Kind = SymbolKind::Enum; break;
122 }
123
124 if (const CXXRecordDecl *CXXRec = dyn_cast<CXXRecordDecl>(D)) {
125 if (!CXXRec->isCLike()) {
126 Info.Lang = SymbolLanguage::CXX;
127 if (CXXRec->getDescribedClassTemplate()) {
128 Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
129 }
130 }
131 }
132
133 if (isa<ClassTemplatePartialSpecializationDecl>(D)) {
134 Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
135 Info.Properties |=
136 (SymbolPropertySet)SymbolProperty::TemplatePartialSpecialization;
137 } else if (isa<ClassTemplateSpecializationDecl>(D)) {
138 Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
139 Info.Properties |=
140 (SymbolPropertySet)SymbolProperty::TemplateSpecialization;
141 }
142
143 } else if (auto *VD = dyn_cast<VarDecl>(D)) {
144 Info.Kind = SymbolKind::Variable;
145 if (isa<ParmVarDecl>(D)) {
146 Info.Kind = SymbolKind::Parameter;
147 } else if (isa<CXXRecordDecl>(D->getDeclContext())) {
148 Info.Kind = SymbolKind::StaticProperty;
149 Info.Lang = SymbolLanguage::CXX;
150 }
151
152 if (isa<VarTemplatePartialSpecializationDecl>(D)) {
153 Info.Lang = SymbolLanguage::CXX;
154 Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
155 Info.Properties |=
156 (SymbolPropertySet)SymbolProperty::TemplatePartialSpecialization;
157 } else if (isa<VarTemplateSpecializationDecl>(D)) {
158 Info.Lang = SymbolLanguage::CXX;
159 Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
160 Info.Properties |=
161 (SymbolPropertySet)SymbolProperty::TemplateSpecialization;
162 } else if (VD->getDescribedVarTemplate()) {
163 Info.Lang = SymbolLanguage::CXX;
164 Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
165 }
166
167 } else {
168 switch (D->getKind()) {
169 case Decl::Import:
170 Info.Kind = SymbolKind::Module;
171 break;
172 case Decl::Typedef:
173 Info.Kind = SymbolKind::TypeAlias; break; // Lang = C
174 case Decl::Function:
175 Info.Kind = SymbolKind::Function;
176 break;
177 case Decl::Field:
178 case Decl::IndirectField:
179 Info.Kind = SymbolKind::Field;
180 if (const CXXRecordDecl *
181 CXXRec = dyn_cast<CXXRecordDecl>(D->getDeclContext())) {
182 if (!CXXRec->isCLike())
183 Info.Lang = SymbolLanguage::CXX;
184 }
185 break;
186 case Decl::EnumConstant:
187 Info.Kind = SymbolKind::EnumConstant; break;
188 case Decl::ObjCInterface:
189 case Decl::ObjCImplementation: {
190 Info.Kind = SymbolKind::Class;
191 Info.Lang = SymbolLanguage::ObjC;
192 const ObjCInterfaceDecl *ClsD = dyn_cast<ObjCInterfaceDecl>(D);
193 if (!ClsD)
194 ClsD = cast<ObjCImplementationDecl>(D)->getClassInterface();
195 if (isUnitTestCase(ClsD))
196 Info.Properties |= (SymbolPropertySet)SymbolProperty::UnitTest;
197 break;
198 }
199 case Decl::ObjCProtocol:
200 Info.Kind = SymbolKind::Protocol;
201 Info.Lang = SymbolLanguage::ObjC;
202 break;
203 case Decl::ObjCCategory:
204 case Decl::ObjCCategoryImpl: {
205 Info.Kind = SymbolKind::Extension;
206 Info.Lang = SymbolLanguage::ObjC;
207 const ObjCInterfaceDecl *ClsD = nullptr;
208 if (auto *CatD = dyn_cast<ObjCCategoryDecl>(D))
209 ClsD = CatD->getClassInterface();
210 else
211 ClsD = cast<ObjCCategoryImplDecl>(D)->getClassInterface();
212 if (isUnitTestCase(ClsD))
213 Info.Properties |= (SymbolPropertySet)SymbolProperty::UnitTest;
214 break;
215 }
216 case Decl::ObjCMethod: {
217 const ObjCMethodDecl *MD = cast<ObjCMethodDecl>(D);
218 Info.Kind = MD->isInstanceMethod() ? SymbolKind::InstanceMethod : SymbolKind::ClassMethod;
219 if (MD->isPropertyAccessor()) {
220 if (MD->param_size())
221 Info.SubKind = SymbolSubKind::AccessorSetter;
222 else
223 Info.SubKind = SymbolSubKind::AccessorGetter;
224 }
225 Info.Lang = SymbolLanguage::ObjC;
226 if (isUnitTest(MD))
227 Info.Properties |= (SymbolPropertySet)SymbolProperty::UnitTest;
228 if (D->hasAttr<IBActionAttr>())
229 Info.Properties |= (SymbolPropertySet)SymbolProperty::IBAnnotated;
230 break;
231 }
232 case Decl::ObjCProperty:
233 Info.Kind = SymbolKind::InstanceProperty;
234 Info.Lang = SymbolLanguage::ObjC;
236 if (auto *Annot = D->getAttr<AnnotateAttr>()) {
237 if (Annot->getAnnotation() == "gk_inspectable")
238 Info.Properties |= (SymbolPropertySet)SymbolProperty::GKInspectable;
239 }
240 break;
241 case Decl::ObjCIvar:
242 Info.Kind = SymbolKind::Field;
243 Info.Lang = SymbolLanguage::ObjC;
245 break;
246 case Decl::Namespace:
247 Info.Kind = SymbolKind::Namespace;
248 Info.Lang = SymbolLanguage::CXX;
249 break;
250 case Decl::NamespaceAlias:
251 Info.Kind = SymbolKind::NamespaceAlias;
252 Info.Lang = SymbolLanguage::CXX;
253 break;
254 case Decl::CXXConstructor: {
255 Info.Kind = SymbolKind::Constructor;
256 Info.Lang = SymbolLanguage::CXX;
257 auto *CD = cast<CXXConstructorDecl>(D);
258 if (CD->isCopyConstructor())
259 Info.SubKind = SymbolSubKind::CXXCopyConstructor;
260 else if (CD->isMoveConstructor())
261 Info.SubKind = SymbolSubKind::CXXMoveConstructor;
262 break;
263 }
264 case Decl::CXXDestructor:
265 Info.Kind = SymbolKind::Destructor;
266 Info.Lang = SymbolLanguage::CXX;
267 break;
268 case Decl::CXXConversion:
269 Info.Kind = SymbolKind::ConversionFunction;
270 Info.Lang = SymbolLanguage::CXX;
271 break;
272 case Decl::CXXMethod: {
273 const CXXMethodDecl *MD = cast<CXXMethodDecl>(D);
274 if (MD->isStatic())
275 Info.Kind = SymbolKind::StaticMethod;
276 else
277 Info.Kind = SymbolKind::InstanceMethod;
278 Info.Lang = SymbolLanguage::CXX;
279 break;
280 }
281 case Decl::ClassTemplate:
282 Info.Kind = SymbolKind::Class;
283 Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
284 Info.Lang = SymbolLanguage::CXX;
285 break;
286 case Decl::FunctionTemplate:
287 Info.Kind = SymbolKind::Function;
288 Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
289 Info.Lang = SymbolLanguage::CXX;
290 if (const CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(
291 cast<FunctionTemplateDecl>(D)->getTemplatedDecl())) {
292 if (isa<CXXConstructorDecl>(MD))
293 Info.Kind = SymbolKind::Constructor;
294 else if (isa<CXXDestructorDecl>(MD))
295 Info.Kind = SymbolKind::Destructor;
296 else if (isa<CXXConversionDecl>(MD))
297 Info.Kind = SymbolKind::ConversionFunction;
298 else {
299 if (MD->isStatic())
300 Info.Kind = SymbolKind::StaticMethod;
301 else
302 Info.Kind = SymbolKind::InstanceMethod;
303 }
304 }
305 break;
306 case Decl::TypeAliasTemplate:
307 Info.Kind = SymbolKind::TypeAlias;
308 Info.Lang = SymbolLanguage::CXX;
309 Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
310 break;
311 case Decl::TypeAlias:
312 Info.Kind = SymbolKind::TypeAlias;
313 Info.Lang = SymbolLanguage::CXX;
314 break;
315 case Decl::UnresolvedUsingTypename:
316 Info.Kind = SymbolKind::Using;
317 Info.SubKind = SymbolSubKind::UsingTypename;
318 Info.Lang = SymbolLanguage::CXX;
319 Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
320 break;
321 case Decl::UnresolvedUsingValue:
322 Info.Kind = SymbolKind::Using;
323 Info.SubKind = SymbolSubKind::UsingValue;
324 Info.Lang = SymbolLanguage::CXX;
325 Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
326 break;
327 case Decl::Using:
328 Info.Kind = SymbolKind::Using;
329 Info.Lang = SymbolLanguage::CXX;
330 break;
331 case Decl::UsingEnum:
332 Info.Kind = SymbolKind::Using;
333 Info.Lang = SymbolLanguage::CXX;
334 Info.SubKind = SymbolSubKind::UsingEnum;
335 break;
336 case Decl::Binding:
337 Info.Kind = SymbolKind::Variable;
338 Info.Lang = SymbolLanguage::CXX;
339 break;
340 case Decl::MSProperty:
341 Info.Kind = SymbolKind::InstanceProperty;
342 if (const CXXRecordDecl *CXXRec =
343 dyn_cast<CXXRecordDecl>(D->getDeclContext())) {
344 if (!CXXRec->isCLike())
345 Info.Lang = SymbolLanguage::CXX;
346 }
347 break;
348 case Decl::ClassTemplatePartialSpecialization:
349 case Decl::ClassScopeFunctionSpecialization:
350 case Decl::ClassTemplateSpecialization:
351 case Decl::CXXRecord:
352 case Decl::Enum:
353 case Decl::Record:
354 llvm_unreachable("records handled before");
355 break;
356 case Decl::VarTemplateSpecialization:
357 case Decl::VarTemplatePartialSpecialization:
358 case Decl::ImplicitParam:
359 case Decl::ParmVar:
360 case Decl::Var:
361 case Decl::VarTemplate:
362 llvm_unreachable("variables handled before");
363 break;
364 case Decl::TemplateTypeParm:
365 Info.Kind = SymbolKind::TemplateTypeParm;
366 break;
367 case Decl::TemplateTemplateParm:
368 Info.Kind = SymbolKind::TemplateTemplateParm;
369 break;
370 case Decl::NonTypeTemplateParm:
371 Info.Kind = SymbolKind::NonTypeTemplateParm;
372 break;
373 case Decl::Concept:
374 Info.Kind = SymbolKind::Concept;
375 break;
376 // Other decls get the 'unknown' kind.
377 default:
378 break;
379 }
380 }
381
382 if (Info.Kind == SymbolKind::Unknown)
383 return Info;
384
385 if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
386 if (FD->getTemplatedKind() ==
388 Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
389 Info.Properties |=
390 (SymbolPropertySet)SymbolProperty::TemplateSpecialization;
391 }
392 }
393
394 if (Info.Properties & (SymbolPropertySet)SymbolProperty::Generic)
395 Info.Lang = SymbolLanguage::CXX;
396
397 if (auto *attr = D->getExternalSourceSymbolAttr()) {
398 if (attr->getLanguage() == "Swift")
399 Info.Lang = SymbolLanguage::Swift;
400 }
401
402 return Info;
403}
404
406 SymbolInfo Info;
407 Info.Kind = SymbolKind::Macro;
408 Info.SubKind = SymbolSubKind::None;
410 Info.Lang = SymbolLanguage::C;
411 return Info;
412}
413
415 llvm::function_ref<bool(SymbolRole)> Fn) {
416#define APPLY_FOR_ROLE(Role) \
417 if (Roles & (unsigned)SymbolRole::Role) \
418 if (!Fn(SymbolRole::Role)) \
419 return false;
420
442
443#undef APPLY_FOR_ROLE
444
445 return true;
446}
447
449 llvm::function_ref<void(SymbolRole)> Fn) {
450 applyForEachSymbolRoleInterruptible(Roles, [&](SymbolRole r) -> bool {
451 Fn(r);
452 return true;
453 });
454}
455
456void index::printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS) {
457 bool VisitedOnce = false;
458 applyForEachSymbolRole(Roles, [&](SymbolRole Role) {
459 if (VisitedOnce)
460 OS << ',';
461 else
462 VisitedOnce = true;
463 switch (Role) {
464 case SymbolRole::Declaration: OS << "Decl"; break;
465 case SymbolRole::Definition: OS << "Def"; break;
466 case SymbolRole::Reference: OS << "Ref"; break;
467 case SymbolRole::Read: OS << "Read"; break;
468 case SymbolRole::Write: OS << "Writ"; break;
469 case SymbolRole::Call: OS << "Call"; break;
470 case SymbolRole::Dynamic: OS << "Dyn"; break;
471 case SymbolRole::AddressOf: OS << "Addr"; break;
472 case SymbolRole::Implicit: OS << "Impl"; break;
473 case SymbolRole::Undefinition: OS << "Undef"; break;
474 case SymbolRole::RelationChildOf: OS << "RelChild"; break;
475 case SymbolRole::RelationBaseOf: OS << "RelBase"; break;
476 case SymbolRole::RelationOverrideOf: OS << "RelOver"; break;
477 case SymbolRole::RelationReceivedBy: OS << "RelRec"; break;
478 case SymbolRole::RelationCalledBy: OS << "RelCall"; break;
479 case SymbolRole::RelationExtendedBy: OS << "RelExt"; break;
480 case SymbolRole::RelationAccessorOf: OS << "RelAcc"; break;
481 case SymbolRole::RelationContainedBy: OS << "RelCont"; break;
482 case SymbolRole::RelationIBTypeOf: OS << "RelIBType"; break;
483 case SymbolRole::RelationSpecializationOf: OS << "RelSpecialization"; break;
484 case SymbolRole::NameReference: OS << "NameReference"; break;
485 }
486 });
487}
488
489bool index::printSymbolName(const Decl *D, const LangOptions &LO,
490 raw_ostream &OS) {
491 if (auto *ND = dyn_cast<NamedDecl>(D)) {
492 PrintingPolicy Policy(LO);
493 // Forward references can have different template argument names. Suppress
494 // the template argument names in constructors to make their name more
495 // stable.
497 DeclarationName DeclName = ND->getDeclName();
498 if (DeclName.isEmpty())
499 return true;
500 DeclName.print(OS, Policy);
501 return false;
502 } else {
503 return true;
504 }
505}
506
508 switch (K) {
509 case SymbolKind::Unknown: return "<unknown>";
510 case SymbolKind::Module: return "module";
511 case SymbolKind::Namespace: return "namespace";
512 case SymbolKind::NamespaceAlias: return "namespace-alias";
513 case SymbolKind::Macro: return "macro";
514 case SymbolKind::Enum: return "enum";
515 case SymbolKind::Struct: return "struct";
516 case SymbolKind::Class: return "class";
517 case SymbolKind::Protocol: return "protocol";
518 case SymbolKind::Extension: return "extension";
519 case SymbolKind::Union: return "union";
520 case SymbolKind::TypeAlias: return "type-alias";
521 case SymbolKind::Function: return "function";
522 case SymbolKind::Variable: return "variable";
523 case SymbolKind::Field: return "field";
524 case SymbolKind::EnumConstant: return "enumerator";
525 case SymbolKind::InstanceMethod: return "instance-method";
526 case SymbolKind::ClassMethod: return "class-method";
527 case SymbolKind::StaticMethod: return "static-method";
528 case SymbolKind::InstanceProperty: return "instance-property";
529 case SymbolKind::ClassProperty: return "class-property";
530 case SymbolKind::StaticProperty: return "static-property";
531 case SymbolKind::Constructor: return "constructor";
532 case SymbolKind::Destructor: return "destructor";
533 case SymbolKind::ConversionFunction: return "conversion-func";
534 case SymbolKind::Parameter: return "param";
535 case SymbolKind::Using: return "using";
536 case SymbolKind::TemplateTypeParm: return "template-type-param";
537 case SymbolKind::TemplateTemplateParm: return "template-template-param";
538 case SymbolKind::NonTypeTemplateParm: return "non-type-template-param";
539 case SymbolKind::Concept:
540 return "concept";
541 }
542 llvm_unreachable("invalid symbol kind");
543}
544
546 switch (K) {
547 case SymbolSubKind::None: return "<none>";
548 case SymbolSubKind::CXXCopyConstructor: return "cxx-copy-ctor";
549 case SymbolSubKind::CXXMoveConstructor: return "cxx-move-ctor";
550 case SymbolSubKind::AccessorGetter: return "acc-get";
551 case SymbolSubKind::AccessorSetter: return "acc-set";
552 case SymbolSubKind::UsingTypename: return "using-typename";
553 case SymbolSubKind::UsingValue: return "using-value";
554 case SymbolSubKind::UsingEnum:
555 return "using-enum";
556 }
557 llvm_unreachable("invalid symbol subkind");
558}
559
561 switch (K) {
562 case SymbolLanguage::C: return "C";
563 case SymbolLanguage::ObjC: return "ObjC";
564 case SymbolLanguage::CXX: return "C++";
565 case SymbolLanguage::Swift: return "Swift";
566 }
567 llvm_unreachable("invalid symbol language kind");
568}
569
571 llvm::function_ref<void(SymbolProperty)> Fn) {
572#define APPLY_FOR_PROPERTY(K) \
573 if (Props & (SymbolPropertySet)SymbolProperty::K) \
574 Fn(SymbolProperty::K)
575
585
586#undef APPLY_FOR_PROPERTY
587}
588
590 bool VisitedOnce = false;
592 if (VisitedOnce)
593 OS << ',';
594 else
595 VisitedOnce = true;
596 switch (Prop) {
597 case SymbolProperty::Generic: OS << "Gen"; break;
598 case SymbolProperty::TemplatePartialSpecialization: OS << "TPS"; break;
599 case SymbolProperty::TemplateSpecialization: OS << "TS"; break;
600 case SymbolProperty::UnitTest: OS << "test"; break;
601 case SymbolProperty::IBAnnotated: OS << "IB"; break;
602 case SymbolProperty::IBOutletCollection: OS << "IBColl"; break;
603 case SymbolProperty::GKInspectable: OS << "GKI"; break;
604 case SymbolProperty::Local: OS << "local"; break;
605 case SymbolProperty::ProtocolInterface: OS << "protocol"; break;
606 }
607 });
608}
@ Write
Definition: CGBuiltin.cpp:7899
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
#define APPLY_FOR_PROPERTY(K)
static bool isUnitTest(const ObjCMethodDecl *D)
Definition: IndexSymbol.cpp:34
#define APPLY_FOR_ROLE(Role)
static void checkForIBOutlets(const Decl *D, SymbolPropertySet &PropSet)
Definition: IndexSymbol.cpp:44
static bool isUnitTestCase(const ObjCInterfaceDecl *D)
Definition: IndexSymbol.cpp:21
Defines the clang::MacroInfo and clang::MacroDirective classes.
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2035
bool isStatic() const
Definition: DeclCXX.cpp:2144
Represents a C++ struct/union/class.
Definition: DeclCXX.h:254
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:83
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:296
T * getAttr() const
Definition: DeclBase.h:556
DeclContext * getDeclContext()
Definition: DeclBase.h:441
bool hasAttr() const
Definition: DeclBase.h:560
Kind getKind() const
Definition: DeclBase.h:435
The name of a declaration.
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
bool isEmpty() const
Evaluates true when this declaration name is empty.
Represents a function declaration or definition.
Definition: Decl.h:1919
@ TK_FunctionTemplateSpecialization
Definition: Decl.h:1935
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:83
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:39
This represents a decl that may have a name.
Definition: Decl.h:247
Represents an ObjC class declaration.
Definition: DeclObjC.h:1147
ObjCInterfaceDecl * getSuperClass() const
Definition: DeclObjC.cpp:351
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:138
ArrayRef< ParmVarDecl * > parameters() const
Definition: DeclObjC.h:375
unsigned param_size() const
Definition: DeclObjC.h:349
bool isPropertyAccessor() const
Definition: DeclObjC.h:438
Selector getSelector() const
Definition: DeclObjC.h:329
bool isInstanceMethod() const
Definition: DeclObjC.h:428
QualType getReturnType() const
Definition: DeclObjC.h:331
ObjCInterfaceDecl * getClassInterface()
Definition: DeclObjC.cpp:1211
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3477
bool isVoidType() const
Definition: Type.h:7317
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
void applyForEachSymbolProperty(SymbolPropertySet Props, llvm::function_ref< void(SymbolProperty)> Fn)
SymbolRole
Set of roles that are attributed to symbol occurrences.
Definition: IndexSymbol.h:102
StringRef getSymbolSubKindString(SymbolSubKind K)
void printSymbolProperties(SymbolPropertySet Props, raw_ostream &OS)
SymbolInfo getSymbolInfo(const Decl *D)
Definition: IndexSymbol.cpp:84
StringRef getSymbolKindString(SymbolKind K)
bool isFunctionLocalSymbol(const Decl *D)
Definition: IndexSymbol.cpp:53
void applyForEachSymbolRole(SymbolRoleSet Roles, llvm::function_ref< void(SymbolRole)> Fn)
void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS)
SymbolInfo getSymbolInfoForMacro(const MacroInfo &MI)
bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS)
bool applyForEachSymbolRoleInterruptible(SymbolRoleSet Roles, llvm::function_ref< bool(SymbolRole)> Fn)
SymbolProperty
Set of properties that provide additional info about a symbol.
Definition: IndexSymbol.h:85
@ ProtocolInterface
Symbol is part of a protocol interface.
uint16_t SymbolPropertySet
Definition: IndexSymbol.h:83
StringRef getSymbolLanguageString(SymbolLanguage K)
SymbolSubKind
Language specific sub-kinds.
Definition: IndexSymbol.h:72
@ InternalLinkage
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
Definition: Linkage.h:31
@ ModuleLinkage
Module linkage, which indicates that the entity can be referred to from other translation units withi...
Definition: Linkage.h:50
@ NoLinkage
No linkage, which means that the entity is unique and can only be referred to from within its scope.
Definition: Linkage.h:26
@ ExternalLinkage
External linkage, which indicates that the entity can be referred to from other translation units.
Definition: Linkage.h:54
@ UniqueExternalLinkage
External linkage within a unique namespace.
Definition: Linkage.h:40
@ VisibleNoLinkage
No linkage according to the standard, but is visible from other translation units because of types de...
Definition: Linkage.h:44
@ TTK_Class
The "class" keyword.
Definition: Type.h:5670
@ TTK_Enum
The "enum" keyword.
Definition: Type.h:5673
@ TTK_Struct
The "struct" keyword.
Definition: Type.h:5661
@ TTK_Union
The "union" keyword.
Definition: Type.h:5667
@ TTK_Interface
The "__interface" keyword.
Definition: Type.h:5664
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
Describes how types, statements, expressions, and declarations should be printed.
Definition: PrettyPrinter.h:57
unsigned SuppressTemplateArgsInCXXConstructors
When true, suppresses printing template arguments in names of C++ constructors.
SymbolPropertySet Properties
Definition: IndexSymbol.h:148