summaryrefslogtreecommitdiffstats
path: root/clang/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
commit49a844e1a68e665b643e842b87020af78c01d4c8 (patch)
tree44e2ea112fbcbb3167f7741d10cb8cefff9e7dfb /clang/lib/Analysis/CFRefCount.cpp
parentfa552d728dfcff0d436d6e881cf042b27df9282f (diff)
downloadbcm5719-llvm-49a844e1a68e665b643e842b87020af78c01d4c8.tar.gz
bcm5719-llvm-49a844e1a68e665b643e842b87020af78c01d4c8.zip
retain checker: Add checker support for FunctionDecl ownership annotations. Need to add Sema support.
llvm-svn: 70873
Diffstat (limited to 'clang/lib/Analysis/CFRefCount.cpp')
-rw-r--r--clang/lib/Analysis/CFRefCount.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/lib/Analysis/CFRefCount.cpp b/clang/lib/Analysis/CFRefCount.cpp
index 59d48452503..711127b79d9 100644
--- a/clang/lib/Analysis/CFRefCount.cpp
+++ b/clang/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;
OpenPOWER on IntegriCloud