@@ -382,6 +382,14 @@ void USRGenerator::VisitNamespaceAliasDecl(const NamespaceAliasDecl *D) {
382382 Out << " @NA@" << D->getName ();
383383}
384384
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+
385393void USRGenerator::VisitObjCMethodDecl (const ObjCMethodDecl *D) {
386394 const DeclContext *container = D->getDeclContext ();
387395 if (const ObjCProtocolDecl *pd = dyn_cast<ObjCProtocolDecl>(container)) {
@@ -395,14 +403,6 @@ void USRGenerator::VisitObjCMethodDecl(const ObjCMethodDecl *D) {
395403 IgnoreResults = true ;
396404 return ;
397405 }
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- };
406406 auto *CD = getCategoryContext (D);
407407 VisitObjCContainerDecl (ID, CD);
408408 }
@@ -475,7 +475,7 @@ void USRGenerator::VisitObjCPropertyDecl(const ObjCPropertyDecl *D) {
475475 // The USR for a property declared in a class extension or category is based
476476 // on the ObjCInterfaceDecl, not the ObjCCategoryDecl.
477477 if (const ObjCInterfaceDecl *ID = Context->getObjContainingInterface (D))
478- Visit (ID);
478+ VisitObjCContainerDecl (ID, getCategoryContext (D) );
479479 else
480480 Visit (cast<Decl>(D->getDeclContext ()));
481481 GenObjCProperty (D->getName (), D->isClassProperty ());
0 commit comments