From: Jordan Rose Date: Mon, 6 Aug 2012 21:28:02 +0000 (+0000) Subject: [analyzer] Ignore OS X 10.8's annotations for NSMakeCollectable. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=15d18e15384c9e992bd294fc56f4fdf770763d71;p=clang [analyzer] Ignore OS X 10.8's annotations for NSMakeCollectable. The frameworks correctly use the 'cf_consumed' and 'ns_returns_retained' attributes for NSMakeCollectable, but we can model the behavior under garbage collection more precisely than that. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161349 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index 53656cf6a0..86e6cae826 100644 --- a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -981,6 +981,7 @@ RetainSummaryManager::getFunctionSummary(const FunctionDecl *FD) { // No summary? Generate one. const RetainSummary *S = 0; + bool AllowAnnotations = true; do { // We generate "stop" summaries for implicitly defined functions. @@ -1018,6 +1019,9 @@ RetainSummaryManager::getFunctionSummary(const FunctionDecl *FD) { S = (RetTy->isObjCIdType()) ? getUnarySummary(FT, cfmakecollectable) : getPersistentStopSummary(); + // The headers on OS X 10.8 use cf_consumed/ns_returns_retained, + // but we can fully model NSMakeCollectable ourselves. + AllowAnnotations = false; } else if (FName == "IOBSDNameMatching" || FName == "IOServiceMatching" || FName == "IOServiceNameMatching" || @@ -1178,7 +1182,8 @@ RetainSummaryManager::getFunctionSummary(const FunctionDecl *FD) { S = getDefaultSummary(); // Annotations override defaults. - updateSummaryFromAnnotations(S, FD); + if (AllowAnnotations) + updateSummaryFromAnnotations(S, FD); FuncSummaries[FD] = S; return S;