Index: clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp +++ clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp @@ -513,7 +513,8 @@ os << "that is annotated as CF_RETURNS_NOT_RETAINED"; } else if (D->hasAttr()) { os << "that is annotated as NS_RETURNS_NOT_RETAINED"; - // TODO: once the patch is ready, insert a case for OS_RETURNS_NOT_RETAINED + } else if (D->hasAttr()) { + os << "that is annotated as OS_RETURNS_NOT_RETAINED"; } else { if (const ObjCMethodDecl *MD = dyn_cast(D)) { if (BRC.getASTContext().getLangOpts().ObjCAutoRefCount) { Index: clang/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp +++ clang/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp @@ -664,15 +664,21 @@ return None; } - if (D->hasAttr()) + if (D->hasAttr()) { return RetEffect::MakeOwned(RetEffect::CF); - else if (hasRCAnnotation(D, "rc_ownership_returns_retained")) + } else if (D->hasAttr()) { + return RetEffect::MakeOwned(RetEffect::OS); + } else if (hasRCAnnotation(D, "rc_ownership_returns_retained")) { return RetEffect::MakeOwned(RetEffect::Generalized); + } - if (D->hasAttr()) + if (D->hasAttr()) { return RetEffect::MakeNotOwned(RetEffect::CF); - else if (hasRCAnnotation(D, "rc_ownership_returns_not_retained")) + } else if (D->hasAttr()) { + return RetEffect::MakeNotOwned(RetEffect::OS); + } else if (hasRCAnnotation(D, "rc_ownership_returns_not_retained")) { return RetEffect::MakeNotOwned(RetEffect::Generalized); + } return None; } @@ -688,15 +694,16 @@ // Effects on the parameters. unsigned parm_idx = 0; - for (FunctionDecl::param_const_iterator pi = FD->param_begin(), + for (auto pi = FD->param_begin(), pe = FD->param_end(); pi != pe; ++pi, ++parm_idx) { const ParmVarDecl *pd = *pi; - if (pd->hasAttr()) + if (pd->hasAttr()) { Template->addArg(AF, parm_idx, DecRefMsg); - else if (pd->hasAttr() || - hasRCAnnotation(pd, "rc_ownership_consumed")) + } else if (pd->hasAttr() || + pd->hasAttr() || + hasRCAnnotation(pd, "rc_ownership_consumed")) { Template->addArg(AF, parm_idx, DecRef); - else if (pd->hasAttr() || + } else if (pd->hasAttr() || hasRCAnnotation(pd, "rc_ownership_returns_retained")) { QualType PointeeTy = pd->getType()->getPointeeType(); if (!PointeeTy.isNull()) @@ -734,9 +741,9 @@ pi=MD->param_begin(), pe=MD->param_end(); pi != pe; ++pi, ++parm_idx) { const ParmVarDecl *pd = *pi; - if (pd->hasAttr()) + if (pd->hasAttr()) { Template->addArg(AF, parm_idx, DecRefMsg); - else if (pd->hasAttr()) { + } else if (pd->hasAttr() || pd->hasAttr()) { Template->addArg(AF, parm_idx, DecRef); } else if (pd->hasAttr()) { QualType PointeeTy = pd->getType()->getPointeeType(); Index: clang/test/Analysis/osobject-retain-release.cpp =================================================================== --- clang/test/Analysis/osobject-retain-release.cpp +++ clang/test/Analysis/osobject-retain-release.cpp @@ -2,9 +2,9 @@ struct OSMetaClass; -#define OS_CONSUME __attribute__((annotate("rc_ownership_consumed"))) -#define OS_RETURNS_RETAINED __attribute__((annotate("rc_ownership_returns_retained"))) -#define OS_RETURNS_NOT_RETAINED __attribute__((annotate("rc_ownership_returns_not_retained"))) +#define OS_CONSUME __attribute__((os_consumed)) +#define OS_RETURNS_RETAINED __attribute__((os_returns_retained)) +#define OS_RETURNS_NOT_RETAINED __attribute__((os_returns_not_retained)) #define OSTypeID(type) (type::metaClass)