16 using namespace clang;
17 using namespace clang::index;
24 if (SuperD->getName() ==
"XCTestCase")
44 if (D->
hasAttr<IBOutletAttr>()) {
46 }
else if (D->
hasAttr<IBOutletCollectionAttr>()) {
55 if (isa<ParmVarDecl>(D))
58 if (isa<TemplateTemplateParmDecl>(D))
61 if (isa<ObjCTypeParamDecl>(D))
64 if (isa<UsingDirectiveDecl>(D))
69 if (
const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
70 switch (ND->getFormalLinkage()) {
77 llvm_unreachable(
"Not a sema linkage");
99 if (
const TagDecl *TD = dyn_cast<TagDecl>(D)) {
100 switch (TD->getTagKind()) {
117 if (
const CXXRecordDecl *CXXRec = dyn_cast<CXXRecordDecl>(D)) {
118 if (!CXXRec->isCLike()) {
120 if (CXXRec->getDescribedClassTemplate()) {
126 if (isa<ClassTemplatePartialSpecializationDecl>(D)) {
129 }
else if (isa<ClassTemplateSpecializationDecl>(D)) {
134 }
else if (
auto *VD = dyn_cast<VarDecl>(D)) {
136 if (isa<ParmVarDecl>(D)) {
143 if (isa<VarTemplatePartialSpecializationDecl>(D)) {
147 }
else if (isa<VarTemplateSpecializationDecl>(D)) {
151 }
else if (VD->getDescribedVarTemplate()) {
170 if (!CXXRec->isCLike())
176 case Decl::ObjCInterface:
177 case Decl::ObjCImplementation: {
182 ClsD = cast<ObjCImplementationDecl>(D)->getClassInterface();
187 case Decl::ObjCProtocol:
191 case Decl::ObjCCategory:
192 case Decl::ObjCCategoryImpl: {
196 if (
auto *CatD = dyn_cast<ObjCCategoryDecl>(D))
197 ClsD = CatD->getClassInterface();
199 ClsD = cast<ObjCCategoryImplDecl>(D)->getClassInterface();
204 case Decl::ObjCMethod:
205 if (cast<ObjCMethodDecl>(D)->isInstanceMethod()) {
220 if (D->
hasAttr<IBActionAttr>())
223 case Decl::ObjCProperty:
227 if (
auto *Annot = D->
getAttr<AnnotateAttr>()) {
228 if (Annot->getAnnotation() ==
"gk_inspectable")
245 case Decl::CXXConstructor: {
248 auto *CD = cast<CXXConstructorDecl>(D);
249 if (CD->isCopyConstructor())
251 else if (CD->isMoveConstructor())
255 case Decl::CXXDestructor:
259 case Decl::CXXConversion:
263 case Decl::CXXMethod: {
272 case Decl::ClassTemplate:
277 case Decl::FunctionTemplate:
281 if (
const CXXMethodDecl *MD = dyn_cast_or_null<CXXMethodDecl>(
282 cast<FunctionTemplateDecl>(D)->getTemplatedDecl())) {
283 if (isa<CXXConstructorDecl>(MD))
285 else if (isa<CXXDestructorDecl>(MD))
287 else if (isa<CXXConversionDecl>(MD))
297 case Decl::TypeAliasTemplate:
318 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
319 if (FD->getTemplatedKind() ==
329 if (
auto *attr = D->getExternalSourceSymbolAttr()) {
330 if (attr->getLanguage() ==
"Swift")
339 #define APPLY_FOR_ROLE(Role) \
340 if (Roles & (unsigned)SymbolRole::Role) \
341 if (!Fn(SymbolRole::Role)) \
364 #undef APPLY_FOR_ROLE
378 bool VisitedOnce =
false;
385 case SymbolRole::Declaration: OS <<
"Decl";
break;
386 case SymbolRole::Definition: OS <<
"Def";
break;
387 case SymbolRole::Reference: OS <<
"Ref";
break;
388 case SymbolRole::Read: OS <<
"Read";
break;
389 case SymbolRole::Write: OS <<
"Writ";
break;
390 case SymbolRole::Call: OS <<
"Call";
break;
391 case SymbolRole::Dynamic: OS <<
"Dyn";
break;
392 case SymbolRole::AddressOf: OS <<
"Addr";
break;
393 case SymbolRole::Implicit: OS <<
"Impl";
break;
394 case SymbolRole::RelationChildOf: OS <<
"RelChild";
break;
395 case SymbolRole::RelationBaseOf: OS <<
"RelBase";
break;
396 case SymbolRole::RelationOverrideOf: OS <<
"RelOver";
break;
397 case SymbolRole::RelationReceivedBy: OS <<
"RelRec";
break;
398 case SymbolRole::RelationCalledBy: OS <<
"RelCall";
break;
399 case SymbolRole::RelationExtendedBy: OS <<
"RelExt";
break;
400 case SymbolRole::RelationAccessorOf: OS <<
"RelAcc";
break;
401 case SymbolRole::RelationContainedBy: OS <<
"RelCont";
break;
402 case SymbolRole::RelationIBTypeOf: OS <<
"RelIBType";
break;
403 case SymbolRole::RelationSpecializationOf: OS <<
"RelSpecialization";
break;
410 if (
auto *ND = dyn_cast<NamedDecl>(D)) {
419 DeclName.
print(OS, Policy);
429 case SymbolKind::Module:
return "module";
430 case SymbolKind::Namespace:
return "namespace";
431 case SymbolKind::NamespaceAlias:
return "namespace-alias";
432 case SymbolKind::Macro:
return "macro";
433 case SymbolKind::Enum:
return "enum";
434 case SymbolKind::Struct:
return "struct";
435 case SymbolKind::Class:
return "class";
436 case SymbolKind::Protocol:
return "protocol";
437 case SymbolKind::Extension:
return "extension";
438 case SymbolKind::Union:
return "union";
439 case SymbolKind::TypeAlias:
return "type-alias";
440 case SymbolKind::Function:
return "function";
441 case SymbolKind::Variable:
return "variable";
442 case SymbolKind::Field:
return "field";
443 case SymbolKind::EnumConstant:
return "enumerator";
444 case SymbolKind::InstanceMethod:
return "instance-method";
445 case SymbolKind::ClassMethod:
return "class-method";
446 case SymbolKind::StaticMethod:
return "static-method";
447 case SymbolKind::InstanceProperty:
return "instance-property";
448 case SymbolKind::ClassProperty:
return "class-property";
449 case SymbolKind::StaticProperty:
return "static-property";
450 case SymbolKind::Constructor:
return "constructor";
451 case SymbolKind::Destructor:
return "destructor";
452 case SymbolKind::ConversionFunction:
return "coversion-func";
455 llvm_unreachable(
"invalid symbol kind");
461 case SymbolSubKind::CXXCopyConstructor:
return "cxx-copy-ctor";
462 case SymbolSubKind::CXXMoveConstructor:
return "cxx-move-ctor";
463 case SymbolSubKind::AccessorGetter:
return "acc-get";
464 case SymbolSubKind::AccessorSetter:
return "acc-set";
466 llvm_unreachable(
"invalid symbol subkind");
474 case SymbolLanguage::Swift:
return "Swift";
476 llvm_unreachable(
"invalid symbol language kind");
481 #define APPLY_FOR_PROPERTY(K) \
482 if (Props & (unsigned)SymbolProperty::K) \
483 Fn(SymbolProperty::K)
494 #undef APPLY_FOR_PROPERTY
498 bool VisitedOnce =
false;
505 case SymbolProperty::Generic: OS <<
"Gen";
break;
506 case SymbolProperty::TemplatePartialSpecialization: OS <<
"TPS";
break;
507 case SymbolProperty::TemplateSpecialization: OS <<
"TS";
break;
508 case SymbolProperty::UnitTest: OS <<
"test";
break;
509 case SymbolProperty::IBAnnotated: OS <<
"IB";
break;
510 case SymbolProperty::IBOutletCollection: OS <<
"IBColl";
break;
511 case SymbolProperty::GKInspectable: OS <<
"GKI";
break;
512 case SymbolProperty::Local: OS <<
"local";
break;
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
External linkage, which indicates that the entity can be referred to from other translation units...
StringRef getSymbolLanguageString(SymbolLanguage K)
ObjCInterfaceDecl * getClassInterface()
Internal linkage according to the Modules TS, but can be referred to from other translation units ind...
bool printSymbolName(const Decl *D, const LangOptions &LO, raw_ostream &OS)
No linkage, which means that the entity is unique and can only be referred to from within its scope...
const DeclContext * getParentFunctionOrMethod() const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext...
Decl - This represents one declaration (or definition), e.g.
Defines the C++ template declaration subclasses.
SymbolProperty
Set of properties that provide additional info about a symbol.
The "__interface" keyword.
ObjCMethodDecl - Represents an instance or class method declaration.
Describes how types, statements, expressions, and declarations should be printed. ...
unsigned param_size() const
static bool isUnitTestCase(const ObjCInterfaceDecl *D)
bool applyForEachSymbolRoleInterruptible(SymbolRoleSet Roles, llvm::function_ref< bool(SymbolRole)> Fn)
#define APPLY_FOR_PROPERTY(K)
void applyForEachSymbolProperty(SymbolPropertySet Props, llvm::function_ref< void(SymbolProperty)> Fn)
SymbolRole
Set of roles that are attributed to symbol occurrences.
bool isFunctionLocalSymbol(const Decl *D)
void print(raw_ostream &OS, const PrintingPolicy &Policy)
StringRef getSymbolKindString(SymbolKind K)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
StringRef getSymbolSubKindString(SymbolSubKind K)
Represents an ObjC class declaration.
static bool isUnitTest(const ObjCMethodDecl *D)
unsigned SuppressTemplateArgsInCXXConstructors
When true, suppresses printing template arguments in names of C++ constructors.
Module linkage, which indicates that the entity can be referred to from other translation units withi...
void printSymbolProperties(SymbolPropertySet Props, raw_ostream &OS)
bool isEmpty() const
Evaluates true when this declaration name is empty.
#define APPLY_FOR_ROLE(Role)
DeclContext * getDeclContext()
ArrayRef< ParmVarDecl * > parameters() const
static void checkForIBOutlets(const Decl *D, SymbolPropertySet &PropSet)
SymbolSubKind
Language specific sub-kinds.
TagDecl - Represents the declaration of a struct/union/class/enum.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
Represents a static or instance method of a struct/union/class.
bool isPropertyAccessor() const
unsigned SymbolPropertySet
QualType getReturnType() const
void applyForEachSymbolRole(SymbolRoleSet Roles, llvm::function_ref< void(SymbolRole)> Fn)
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
External linkage within a unique namespace.
DeclarationName - The name of a declaration.
Selector getSelector() const
void printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS)
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
SymbolInfo getSymbolInfo(const Decl *D)
Represents a C++ struct/union/class.
The parameter type of a method or function.
No linkage according to the standard, but is visible from other translation units because of types de...
ObjCInterfaceDecl * getSuperClass() const
NamedDecl - This represents a decl with a name.
SymbolPropertySet Properties