[cfe-commits] r57908 - /cfe/trunk/lib/Analysis/CFRefCount.cpp
Ted Kremenek
kremenek at apple.com
Tue Oct 21 08:53:15 PDT 2008
Author: kremenek
Date: Tue Oct 21 10:53:15 2008
New Revision: 57908
URL: http://llvm.org/viewvc/llvm-project?rev=57908&view=rev
Log:
Handle [NSAutoreleasePool addObject:] (an alternative way to add objects to the current autorelease pool).
Added initial code for tracking stack of autorelease pools.
Modified:
cfe/trunk/lib/Analysis/CFRefCount.cpp
Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=57908&r1=57907&r2=57908&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Tue Oct 21 10:53:15 2008
@@ -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 @@
// 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 @@
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.
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list