aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-10-21 15:53:15 +0000
committerTed Kremenek <kremenek@apple.com>2008-10-21 15:53:15 +0000
commit6d34893fc886f4153f104de8880876764981cb7f (patch)
treee70fe5fe07f34057ce97acda2f887f20d1d72141 /lib
parente117d48049aea4e3abcc809070e62a1cbc1c4274 (diff)
Handle [NSAutoreleasePool addObject:] (an alternative way to add objects to the current autorelease pool).
Added initial code for tracking stack of autorelease pools. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57908 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/CFRefCount.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index e98a6db316..acf4b568ed 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -25,6 +25,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/ImmutableMap.h"
+#include "llvm/ADT/ImmutableList.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Compiler.h"
#include "llvm/ADT/STLExtras.h"
@@ -965,7 +966,16 @@ void RetainSummaryManager::InitializeClassMethodSummaries() {
// Create the [NSAssertionHandler currentHander] summary.
addClsMethSummary(&Ctx.Idents.get("NSAssertionHandler"),
GetNullarySelector("currentHandler", Ctx),
- getPersistentSummary(RetEffect::MakeNotOwned()));
+ getPersistentSummary(RetEffect::MakeNotOwned()));
+
+ // Create the [NSAutoreleasePool addObject:] summary.
+ if (!isGCEnabled()) {
+ ScratchArgs.push_back(std::make_pair(0, Autorelease));
+ addClsMethSummary(&Ctx.Idents.get("NSAutoreleasePool"),
+ GetUnarySelector("addObject", Ctx),
+ getPersistentSummary(RetEffect::MakeNoRet(),
+ DoNothing, DoNothing));
+ }
}
void RetainSummaryManager::InitializeMethodSummaries() {
@@ -1208,7 +1218,22 @@ namespace clang {
static inline void* GDMIndex() { return &RefBIndex; }
};
}
-
+
+//===----------------------------------------------------------------------===//
+// ARBindings - State used to track objects in autorelease pools.
+//===----------------------------------------------------------------------===//
+
+typedef llvm::ImmutableSet<SymbolID> ARPoolContents;
+typedef llvm::ImmutableList< std::pair<SymbolID, ARPoolContents*> > ARBindings;
+static int AutoRBIndex = 0;
+
+namespace clang {
+ template<>
+ struct GRStateTrait<ARBindings> : public GRStatePartialTrait<ARBindings> {
+ static inline void* GDMIndex() { return &AutoRBIndex; }
+ };
+}
+
//===----------------------------------------------------------------------===//
// Transfer functions.
//===----------------------------------------------------------------------===//