Lines Matching defs:D

52 static StringRef GetExternalSourceContainer(const NamedDecl *D) {
53 if (!D)
55 if (auto *attr = D->getExternalSourceSymbolAttr()) {
86 void VisitDeclContext(const DeclContext *D);
87 void VisitFieldDecl(const FieldDecl *D);
88 void VisitFunctionDecl(const FunctionDecl *D);
89 void VisitNamedDecl(const NamedDecl *D);
90 void VisitNamespaceDecl(const NamespaceDecl *D);
91 void VisitNamespaceAliasDecl(const NamespaceAliasDecl *D);
92 void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D);
93 void VisitClassTemplateDecl(const ClassTemplateDecl *D);
97 void VisitObjCPropertyDecl(const ObjCPropertyDecl *D);
98 void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
99 void VisitTagDecl(const TagDecl *D);
100 void VisitTypedefDecl(const TypedefDecl *D);
101 void VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D);
102 void VisitVarDecl(const VarDecl *D);
103 void VisitBindingDecl(const BindingDecl *D);
104 void VisitNonTypeTemplateParmDecl(const NonTypeTemplateParmDecl *D);
105 void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D);
106 void VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D);
107 void VisitUnresolvedUsingTypenameDecl(const UnresolvedUsingTypenameDecl *D);
108 void VisitConceptDecl(const ConceptDecl *D);
110 void VisitLinkageSpecDecl(const LinkageSpecDecl *D) {
114 void VisitUsingDirectiveDecl(const UsingDirectiveDecl *D) {
118 void VisitUsingDecl(const UsingDecl *D) {
119 VisitDeclContext(D->getDeclContext());
122 bool EmittedDeclName = !EmitDeclName(D);
127 bool ShouldGenerateLocation(const NamedDecl *D);
129 bool isLocal(const NamedDecl *D) {
130 return D->getParentFunctionOrMethod() != nullptr;
133 void GenExtSymbolContainer(const NamedDecl *D);
137 bool GenLoc(const Decl *D, bool IncludeOffset);
173 void VisitMSGuidDecl(const MSGuidDecl *D);
177 bool EmitDeclName(const NamedDecl *D);
185 bool USRGenerator::EmitDeclName(const NamedDecl *D) {
186 DeclarationName N = D->getDeclName();
193 bool USRGenerator::ShouldGenerateLocation(const NamedDecl *D) {
194 if (D->isExternallyVisible())
196 if (D->getParentFunctionOrMethod())
198 SourceLocation Loc = D->getLocation();
206 if (const NamedDecl *D = dyn_cast<NamedDecl>(DC))
207 Visit(D);
212 void USRGenerator::VisitFieldDecl(const FieldDecl *D) {
215 if (const ObjCInterfaceDecl *ID = Context->getObjContainingInterface(D))
218 VisitDeclContext(D->getDeclContext());
219 Out << (isa<ObjCIvarDecl>(D) ? "@" : "@FI@");
220 if (EmitDeclName(D)) {
227 void USRGenerator::VisitFunctionDecl(const FunctionDecl *D) {
228 if (ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D)))
231 if (D->getType().isNull()) {
237 VisitDeclContext(D->getDeclContext());
239 GenExtSymbolContainer(D);
242 if (FunctionTemplateDecl *FunTmpl = D->getDescribedFunctionTemplate()) {
253 D->getDeclName().print(Out, Policy);
256 if ((!Ctx.getLangOpts().CPlusPlus || D->isExternC()) &&
257 !D->hasAttr<OverloadableAttr>())
260 if (D->isFunctionTemplateSpecialization()) {
263 D->getTemplateSpecializationArgs()) {
269 D->getTemplateSpecializationArgsAsWritten()) {
278 QualType CanonicalType = D->getType().getCanonicalType();
286 if (D->isVariadic())
295 VisitType(D->getReturnType());
298 if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) {
312 void USRGenerator::VisitNamedDecl(const NamedDecl *D) {
313 VisitDeclContext(D->getDeclContext());
316 if (EmitDeclName(D)) {
325 void USRGenerator::VisitVarDecl(const VarDecl *D) {
329 if (ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D)))
332 VisitDeclContext(D->getDeclContext());
334 if (VarTemplateDecl *VarTmpl = D->getDescribedVarTemplate()) {
338 = dyn_cast<VarTemplatePartialSpecializationDecl>(D)) {
344 StringRef s = D->getName();
357 = dyn_cast<VarTemplateSpecializationDecl>(D)) {
367 void USRGenerator::VisitBindingDecl(const BindingDecl *D) {
368 if (isLocal(D) && GenLoc(D, /*IncludeOffset=*/true))
370 VisitNamedDecl(D);
374 const NonTypeTemplateParmDecl *D) {
375 GenLoc(D, /*IncludeOffset=*/true);
379 const TemplateTemplateParmDecl *D) {
380 GenLoc(D, /*IncludeOffset=*/true);
383 void USRGenerator::VisitNamespaceDecl(const NamespaceDecl *D) {
386 VisitDeclContext(D->getDeclContext());
387 if (D->isAnonymousNamespace()) {
391 Out << "@N@" << D->getName();
394 void USRGenerator::VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
395 VisitFunctionDecl(D->getTemplatedDecl());
398 void USRGenerator::VisitClassTemplateDecl(const ClassTemplateDecl *D) {
399 VisitTagDecl(D->getTemplatedDecl());
402 void USRGenerator::VisitNamespaceAliasDecl(const NamespaceAliasDecl *D) {
403 VisitDeclContext(D->getDeclContext());
405 Out << "@NA@" << D->getName();
408 static const ObjCCategoryDecl *getCategoryContext(const NamedDecl *D) {
409 if (auto *CD = dyn_cast<ObjCCategoryDecl>(D->getDeclContext()))
411 if (auto *ICD = dyn_cast<ObjCCategoryImplDecl>(D->getDeclContext()))
416 void USRGenerator::VisitObjCMethodDecl(const ObjCMethodDecl *D) {
417 const DeclContext *container = D->getDeclContext();
424 const ObjCInterfaceDecl *ID = D->getClassInterface();
429 auto *CD = getCategoryContext(D);
435 Out << (D->isInstanceMethod() ? "(im)" : "(cm)")
436 << DeclarationName(D->getSelector());
439 void USRGenerator::VisitObjCContainerDecl(const ObjCContainerDecl *D,
441 switch (D->getKind()) {
446 GenObjCClass(D->getName(), GetExternalSourceContainer(D),
450 const ObjCCategoryDecl *CD = cast<ObjCCategoryDecl>(D);
474 const ObjCCategoryImplDecl *CD = cast<ObjCCategoryImplDecl>(D);
490 const ObjCProtocolDecl *PD = cast<ObjCProtocolDecl>(D);
497 void USRGenerator::VisitObjCPropertyDecl(const ObjCPropertyDecl *D) {
500 if (const ObjCInterfaceDecl *ID = Context->getObjContainingInterface(D))
501 VisitObjCContainerDecl(ID, getCategoryContext(D));
503 Visit(cast<Decl>(D->getDeclContext()));
504 GenObjCProperty(D->getName(), D->isClassProperty());
507 void USRGenerator::VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D) {
508 if (ObjCPropertyDecl *PD = D->getPropertyDecl()) {
516 void USRGenerator::VisitTagDecl(const TagDecl *D) {
519 if (!isa<EnumDecl>(D) &&
520 ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D)))
523 GenExtSymbolContainer(D);
525 D = D->getCanonicalDecl();
526 VisitDeclContext(D->getDeclContext());
529 if (const CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(D)) {
533 switch (D->getTagKind()) {
550 switch (D->getTagKind()) {
567 switch (D->getTagKind()) {
586 if (EmitDeclName(D)) {
587 if (const TypedefNameDecl *TD = D->getTypedefNameForAnonDecl()) {
591 if (D->isEmbeddedInDeclarator() && !D->isFreeStanding()) {
592 printLoc(Out, D->getLocation(), Context->getSourceManager(), true);
595 if (auto *ED = dyn_cast<EnumDecl>(D)) {
609 = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
619 void USRGenerator::VisitTypedefDecl(const TypedefDecl *D) {
620 if (ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D)))
622 const DeclContext *DC = D->getDeclContext();
626 Out << D->getName();
629 void USRGenerator::VisitTemplateTypeParmDecl(const TemplateTypeParmDecl *D) {
630 GenLoc(D, /*IncludeOffset=*/true);
633 void USRGenerator::GenExtSymbolContainer(const NamedDecl *D) {
634 StringRef Container = GetExternalSourceContainer(D);
639 bool USRGenerator::GenLoc(const Decl *D, bool IncludeOffset) {
645 if (!D) {
651 D = D->getCanonicalDecl();
654 IgnoreResults || printLoc(Out, D->getBeginLoc(),
746 Out << 'D'; break;
1083 void USRGenerator::VisitUnresolvedUsingValueDecl(const UnresolvedUsingValueDecl *D) {
1084 if (ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D)))
1086 VisitDeclContext(D->getDeclContext());
1088 printQualifier(Out, D->getASTContext(), D->getQualifier());
1089 EmitDeclName(D);
1092 void USRGenerator::VisitUnresolvedUsingTypenameDecl(const UnresolvedUsingTypenameDecl *D) {
1093 if (ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D)))
1095 VisitDeclContext(D->getDeclContext());
1097 printQualifier(Out, D->getASTContext(), D->getQualifier());
1098 Out << D->getName(); // Simple name.
1101 void USRGenerator::VisitConceptDecl(const ConceptDecl *D) {
1102 if (ShouldGenerateLocation(D) && GenLoc(D, /*IncludeOffset=*/isLocal(D)))
1104 VisitDeclContext(D->getDeclContext());
1106 EmitDeclName(D);
1109 void USRGenerator::VisitMSGuidDecl(const MSGuidDecl *D) {
1110 VisitDeclContext(D->getDeclContext());
1112 D->NamedDecl::printName(Out);
1184 bool clang::index::generateUSRForDecl(const Decl *D,
1186 if (!D)
1193 auto *CD = D->getCanonicalDecl();
1201 USRGenerator UG(&D->getASTContext(), Buf);
1202 UG.Visit(D);