aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CFRefCount.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-05-04 16:43:50 +0000
committerTed Kremenek <kremenek@apple.com>2009-05-04 16:43:50 +0000
commitea4b4aaa64d1d2fe59a21cd73ffc4b1ebae9b6ec (patch)
treec99b1d5ea36712d62242c56470df4f996be8703b /lib/Analysis/CFRefCount.cpp
parent05673d61fea9ea656996fe806ece6abf4432075e (diff)
retain checker: Add checker support for FunctionDecl ownership annotations. Need to add Sema support.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70873 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CFRefCount.cpp')
-rw-r--r--lib/Analysis/CFRefCount.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 59d4845250..711127b79d 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -785,6 +785,9 @@ public:
void updateSummaryFromAnnotations(RetainSummary &Summ,
const ObjCMethodDecl *MD);
+ void updateSummaryFromAnnotations(RetainSummary &Summ,
+ const FunctionDecl *FD);
+
bool isGCEnabled() const { return GCEnabled; }
RetainSummary *copySummary(RetainSummary *OldSumm) {
@@ -1009,6 +1012,10 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
if (!S)
S = getDefaultSummary();
+ // Annotations override defaults.
+ assert(S);
+ updateSummaryFromAnnotations(*S, FD);
+
FuncSummaries[FD] = S;
return S;
}
@@ -1112,6 +1119,28 @@ RetainSummaryManager::updateSummaryArgEffFromAnnotations(RetainSummary &Summ,
void
RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ,
+ const FunctionDecl *FD) {
+ if (!FD)
+ return;
+
+ // Determine if there is a special return effect for this method.
+ if (isTrackedObjCObjectType(FD->getResultType())) {
+ if (FD->getAttr<ObjCOwnershipReturnsAttr>()) {
+ Summ.setRetEffect(isGCEnabled()
+ ? RetEffect::MakeGCNotOwned()
+ : RetEffect::MakeOwned(RetEffect::ObjC, true));
+ }
+ }
+
+ // Determine if there are any arguments with a specific ArgEffect.
+ unsigned i = 0;
+ for (FunctionDecl::param_const_iterator I = FD->param_begin(),
+ E = FD->param_end(); I != E; ++I, ++i)
+ updateSummaryArgEffFromAnnotations(Summ, i, *I);
+}
+
+void
+RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ,
const ObjCMethodDecl *MD) {
if (!MD)
return;