[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / lib / Index / IndexSymbol.cpp
blobcfdffeed834e687c9e52b294918288f8dc411f7c
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 //===----------------------------------------------------------------------===//
9 #include "clang/Index/IndexSymbol.h"
10 #include "clang/AST/Attr.h"
11 #include "clang/AST/DeclCXX.h"
12 #include "clang/AST/DeclObjC.h"
13 #include "clang/AST/DeclTemplate.h"
14 #include "clang/AST/PrettyPrinter.h"
15 #include "clang/Lex/MacroInfo.h"
17 using namespace clang;
18 using namespace clang::index;
20 /// \returns true if \c D is a subclass of 'XCTestCase'.
21 static 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;
29 return false;
32 /// \returns true if \c D is in a subclass of 'XCTestCase', returns void, has
33 /// no parameters, and its name starts with 'test'.
34 static 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;
41 return isUnitTestCase(D->getClassInterface());
44 static 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;
53 bool index::isFunctionLocalSymbol(const Decl *D) {
54 assert(D);
56 if (isa<ParmVarDecl>(D))
57 return true;
59 if (isa<ObjCTypeParamDecl>(D))
60 return true;
62 if (isa<UsingDirectiveDecl>(D))
63 return false;
64 if (!D->getParentFunctionOrMethod())
65 return false;
67 if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
68 switch (ND->getFormalLinkage()) {
69 case NoLinkage:
70 case InternalLinkage:
71 return true;
72 case VisibleNoLinkage:
73 case UniqueExternalLinkage:
74 llvm_unreachable("Not a sema linkage");
75 case ModuleLinkage:
76 case ExternalLinkage:
77 return false;
81 return true;
84 SymbolInfo index::getSymbolInfo(const Decl *D) {
85 assert(D);
86 SymbolInfo Info;
87 Info.Kind = SymbolKind::Unknown;
88 Info.SubKind = SymbolSubKind::None;
89 Info.Properties = SymbolPropertySet();
90 Info.Lang = SymbolLanguage::C;
92 if (isFunctionLocalSymbol(D)) {
93 Info.Properties |= (SymbolPropertySet)SymbolProperty::Local;
95 if (isa<ObjCProtocolDecl>(D->getDeclContext())) {
96 Info.Properties |= (SymbolPropertySet)SymbolProperty::ProtocolInterface;
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();
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
232 case Decl::ObjCProperty:
233 Info.Kind = SymbolKind::InstanceProperty;
234 Info.Lang = SymbolLanguage::ObjC;
235 checkForIBOutlets(D, Info.Properties);
236 if (auto *Annot = D->getAttr<AnnotateAttr>()) {
237 if (Annot->getAnnotation() == "gk_inspectable")
238 Info.Properties |= (SymbolPropertySet)SymbolProperty::GKInspectable;
240 break;
241 case Decl::ObjCIvar:
242 Info.Kind = SymbolKind::Field;
243 Info.Lang = SymbolLanguage::ObjC;
244 checkForIBOutlets(D, Info.Properties);
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;
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;
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;
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;
347 break;
348 case Decl::ClassTemplatePartialSpecialization:
349 case Decl::ClassTemplateSpecialization:
350 case Decl::CXXRecord:
351 case Decl::Enum:
352 case Decl::Record:
353 llvm_unreachable("records handled before");
354 break;
355 case Decl::VarTemplateSpecialization:
356 case Decl::VarTemplatePartialSpecialization:
357 case Decl::ImplicitParam:
358 case Decl::ParmVar:
359 case Decl::Var:
360 case Decl::VarTemplate:
361 llvm_unreachable("variables handled before");
362 break;
363 case Decl::TemplateTypeParm:
364 Info.Kind = SymbolKind::TemplateTypeParm;
365 break;
366 case Decl::TemplateTemplateParm:
367 Info.Kind = SymbolKind::TemplateTemplateParm;
368 break;
369 case Decl::NonTypeTemplateParm:
370 Info.Kind = SymbolKind::NonTypeTemplateParm;
371 break;
372 case Decl::Concept:
373 Info.Kind = SymbolKind::Concept;
374 break;
375 // Other decls get the 'unknown' kind.
376 default:
377 break;
381 if (Info.Kind == SymbolKind::Unknown)
382 return Info;
384 if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
385 if (FD->getTemplatedKind() ==
386 FunctionDecl::TK_FunctionTemplateSpecialization) {
387 Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
388 Info.Properties |=
389 (SymbolPropertySet)SymbolProperty::TemplateSpecialization;
393 if (Info.Properties & (SymbolPropertySet)SymbolProperty::Generic)
394 Info.Lang = SymbolLanguage::CXX;
396 if (auto *attr = D->getExternalSourceSymbolAttr()) {
397 if (attr->getLanguage() == "Swift")
398 Info.Lang = SymbolLanguage::Swift;
401 return Info;
404 SymbolInfo index::getSymbolInfoForMacro(const MacroInfo &) {
405 SymbolInfo Info;
406 Info.Kind = SymbolKind::Macro;
407 Info.SubKind = SymbolSubKind::None;
408 Info.Properties = SymbolPropertySet();
409 Info.Lang = SymbolLanguage::C;
410 return Info;
413 bool index::applyForEachSymbolRoleInterruptible(SymbolRoleSet Roles,
414 llvm::function_ref<bool(SymbolRole)> Fn) {
415 #define APPLY_FOR_ROLE(Role) \
416 if (Roles & (unsigned)SymbolRole::Role) \
417 if (!Fn(SymbolRole::Role)) \
418 return false;
420 APPLY_FOR_ROLE(Declaration);
421 APPLY_FOR_ROLE(Definition);
422 APPLY_FOR_ROLE(Reference);
423 APPLY_FOR_ROLE(Read);
424 APPLY_FOR_ROLE(Write);
425 APPLY_FOR_ROLE(Call);
426 APPLY_FOR_ROLE(Dynamic);
427 APPLY_FOR_ROLE(AddressOf);
428 APPLY_FOR_ROLE(Implicit);
429 APPLY_FOR_ROLE(Undefinition);
430 APPLY_FOR_ROLE(RelationChildOf);
431 APPLY_FOR_ROLE(RelationBaseOf);
432 APPLY_FOR_ROLE(RelationOverrideOf);
433 APPLY_FOR_ROLE(RelationReceivedBy);
434 APPLY_FOR_ROLE(RelationCalledBy);
435 APPLY_FOR_ROLE(RelationExtendedBy);
436 APPLY_FOR_ROLE(RelationAccessorOf);
437 APPLY_FOR_ROLE(RelationContainedBy);
438 APPLY_FOR_ROLE(RelationIBTypeOf);
439 APPLY_FOR_ROLE(RelationSpecializationOf);
440 APPLY_FOR_ROLE(NameReference);
442 #undef APPLY_FOR_ROLE
444 return true;
447 void index::applyForEachSymbolRole(SymbolRoleSet Roles,
448 llvm::function_ref<void(SymbolRole)> Fn) {
449 applyForEachSymbolRoleInterruptible(Roles, [&](SymbolRole r) -> bool {
450 Fn(r);
451 return true;
455 void index::printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS) {
456 bool VisitedOnce = false;
457 applyForEachSymbolRole(Roles, [&](SymbolRole Role) {
458 if (VisitedOnce)
459 OS << ',';
460 else
461 VisitedOnce = true;
462 switch (Role) {
463 case SymbolRole::Declaration: OS << "Decl"; break;
464 case SymbolRole::Definition: OS << "Def"; break;
465 case SymbolRole::Reference: OS << "Ref"; break;
466 case SymbolRole::Read: OS << "Read"; break;
467 case SymbolRole::Write: OS << "Writ"; break;
468 case SymbolRole::Call: OS << "Call"; break;
469 case SymbolRole::Dynamic: OS << "Dyn"; break;
470 case SymbolRole::AddressOf: OS << "Addr"; break;
471 case SymbolRole::Implicit: OS << "Impl"; break;
472 case SymbolRole::Undefinition: OS << "Undef"; break;
473 case SymbolRole::RelationChildOf: OS << "RelChild"; break;
474 case SymbolRole::RelationBaseOf: OS << "RelBase"; break;
475 case SymbolRole::RelationOverrideOf: OS << "RelOver"; break;
476 case SymbolRole::RelationReceivedBy: OS << "RelRec"; break;
477 case SymbolRole::RelationCalledBy: OS << "RelCall"; break;
478 case SymbolRole::RelationExtendedBy: OS << "RelExt"; break;
479 case SymbolRole::RelationAccessorOf: OS << "RelAcc"; break;
480 case SymbolRole::RelationContainedBy: OS << "RelCont"; break;
481 case SymbolRole::RelationIBTypeOf: OS << "RelIBType"; break;
482 case SymbolRole::RelationSpecializationOf: OS << "RelSpecialization"; break;
483 case SymbolRole::NameReference: OS << "NameReference"; break;
488 bool index::printSymbolName(const Decl *D, const LangOptions &LO,
489 raw_ostream &OS) {
490 if (auto *ND = dyn_cast<NamedDecl>(D)) {
491 PrintingPolicy Policy(LO);
492 // Forward references can have different template argument names. Suppress
493 // the template argument names in constructors to make their name more
494 // stable.
495 Policy.SuppressTemplateArgsInCXXConstructors = true;
496 DeclarationName DeclName = ND->getDeclName();
497 if (DeclName.isEmpty())
498 return true;
499 DeclName.print(OS, Policy);
500 return false;
501 } else {
502 return true;
506 StringRef index::getSymbolKindString(SymbolKind K) {
507 switch (K) {
508 case SymbolKind::Unknown: return "<unknown>";
509 case SymbolKind::Module: return "module";
510 case SymbolKind::Namespace: return "namespace";
511 case SymbolKind::NamespaceAlias: return "namespace-alias";
512 case SymbolKind::Macro: return "macro";
513 case SymbolKind::Enum: return "enum";
514 case SymbolKind::Struct: return "struct";
515 case SymbolKind::Class: return "class";
516 case SymbolKind::Protocol: return "protocol";
517 case SymbolKind::Extension: return "extension";
518 case SymbolKind::Union: return "union";
519 case SymbolKind::TypeAlias: return "type-alias";
520 case SymbolKind::Function: return "function";
521 case SymbolKind::Variable: return "variable";
522 case SymbolKind::Field: return "field";
523 case SymbolKind::EnumConstant: return "enumerator";
524 case SymbolKind::InstanceMethod: return "instance-method";
525 case SymbolKind::ClassMethod: return "class-method";
526 case SymbolKind::StaticMethod: return "static-method";
527 case SymbolKind::InstanceProperty: return "instance-property";
528 case SymbolKind::ClassProperty: return "class-property";
529 case SymbolKind::StaticProperty: return "static-property";
530 case SymbolKind::Constructor: return "constructor";
531 case SymbolKind::Destructor: return "destructor";
532 case SymbolKind::ConversionFunction: return "conversion-func";
533 case SymbolKind::Parameter: return "param";
534 case SymbolKind::Using: return "using";
535 case SymbolKind::TemplateTypeParm: return "template-type-param";
536 case SymbolKind::TemplateTemplateParm: return "template-template-param";
537 case SymbolKind::NonTypeTemplateParm: return "non-type-template-param";
538 case SymbolKind::Concept:
539 return "concept";
541 llvm_unreachable("invalid symbol kind");
544 StringRef index::getSymbolSubKindString(SymbolSubKind K) {
545 switch (K) {
546 case SymbolSubKind::None: return "<none>";
547 case SymbolSubKind::CXXCopyConstructor: return "cxx-copy-ctor";
548 case SymbolSubKind::CXXMoveConstructor: return "cxx-move-ctor";
549 case SymbolSubKind::AccessorGetter: return "acc-get";
550 case SymbolSubKind::AccessorSetter: return "acc-set";
551 case SymbolSubKind::UsingTypename: return "using-typename";
552 case SymbolSubKind::UsingValue: return "using-value";
553 case SymbolSubKind::UsingEnum:
554 return "using-enum";
556 llvm_unreachable("invalid symbol subkind");
559 StringRef index::getSymbolLanguageString(SymbolLanguage K) {
560 switch (K) {
561 case SymbolLanguage::C: return "C";
562 case SymbolLanguage::ObjC: return "ObjC";
563 case SymbolLanguage::CXX: return "C++";
564 case SymbolLanguage::Swift: return "Swift";
566 llvm_unreachable("invalid symbol language kind");
569 void index::applyForEachSymbolProperty(SymbolPropertySet Props,
570 llvm::function_ref<void(SymbolProperty)> Fn) {
571 #define APPLY_FOR_PROPERTY(K) \
572 if (Props & (SymbolPropertySet)SymbolProperty::K) \
573 Fn(SymbolProperty::K)
575 APPLY_FOR_PROPERTY(Generic);
576 APPLY_FOR_PROPERTY(TemplatePartialSpecialization);
577 APPLY_FOR_PROPERTY(TemplateSpecialization);
578 APPLY_FOR_PROPERTY(UnitTest);
579 APPLY_FOR_PROPERTY(IBAnnotated);
580 APPLY_FOR_PROPERTY(IBOutletCollection);
581 APPLY_FOR_PROPERTY(GKInspectable);
582 APPLY_FOR_PROPERTY(Local);
583 APPLY_FOR_PROPERTY(ProtocolInterface);
585 #undef APPLY_FOR_PROPERTY
588 void index::printSymbolProperties(SymbolPropertySet Props, raw_ostream &OS) {
589 bool VisitedOnce = false;
590 applyForEachSymbolProperty(Props, [&](SymbolProperty Prop) {
591 if (VisitedOnce)
592 OS << ',';
593 else
594 VisitedOnce = true;
595 switch (Prop) {
596 case SymbolProperty::Generic: OS << "Gen"; break;
597 case SymbolProperty::TemplatePartialSpecialization: OS << "TPS"; break;
598 case SymbolProperty::TemplateSpecialization: OS << "TS"; break;
599 case SymbolProperty::UnitTest: OS << "test"; break;
600 case SymbolProperty::IBAnnotated: OS << "IB"; break;
601 case SymbolProperty::IBOutletCollection: OS << "IBColl"; break;
602 case SymbolProperty::GKInspectable: OS << "GKI"; break;
603 case SymbolProperty::Local: OS << "local"; break;
604 case SymbolProperty::ProtocolInterface: OS << "protocol"; break;