@@ -382,6 +382,14 @@ void USRGenerator::VisitNamespaceAliasDecl(const NamespaceAliasDecl *D) {
382
382
Out << " @NA@" << D->getName ();
383
383
}
384
384
385
+ static const ObjCCategoryDecl *getCategoryContext (const NamedDecl *D) {
386
+ if (auto *CD = dyn_cast<ObjCCategoryDecl>(D->getDeclContext ()))
387
+ return CD;
388
+ if (auto *ICD = dyn_cast<ObjCCategoryImplDecl>(D->getDeclContext ()))
389
+ return ICD->getCategoryDecl ();
390
+ return nullptr ;
391
+ };
392
+
385
393
void USRGenerator::VisitObjCMethodDecl (const ObjCMethodDecl *D) {
386
394
const DeclContext *container = D->getDeclContext ();
387
395
if (const ObjCProtocolDecl *pd = dyn_cast<ObjCProtocolDecl>(container)) {
@@ -395,14 +403,6 @@ void USRGenerator::VisitObjCMethodDecl(const ObjCMethodDecl *D) {
395
403
IgnoreResults = true ;
396
404
return ;
397
405
}
398
- auto getCategoryContext = [](const ObjCMethodDecl *D) ->
399
- const ObjCCategoryDecl * {
400
- if (auto *CD = dyn_cast<ObjCCategoryDecl>(D->getDeclContext ()))
401
- return CD;
402
- if (auto *ICD = dyn_cast<ObjCCategoryImplDecl>(D->getDeclContext ()))
403
- return ICD->getCategoryDecl ();
404
- return nullptr ;
405
- };
406
406
auto *CD = getCategoryContext (D);
407
407
VisitObjCContainerDecl (ID, CD);
408
408
}
@@ -475,7 +475,7 @@ void USRGenerator::VisitObjCPropertyDecl(const ObjCPropertyDecl *D) {
475
475
// The USR for a property declared in a class extension or category is based
476
476
// on the ObjCInterfaceDecl, not the ObjCCategoryDecl.
477
477
if (const ObjCInterfaceDecl *ID = Context->getObjContainingInterface (D))
478
- Visit (ID);
478
+ VisitObjCContainerDecl (ID, getCategoryContext (D) );
479
479
else
480
480
Visit (cast<Decl>(D->getDeclContext ()));
481
481
GenObjCProperty (D->getName (), D->isClassProperty ());
0 commit comments