aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Analysis/Support
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2007-10-03 00:48:55 +0000
committerTed Kremenek <kremenek@apple.com>2007-10-03 00:48:55 +0000
commite260e62ddaefa0db5226f88313d30d5b50182d3a (patch)
tree201a03a60492b13712d58934127faf6988994212 /include/clang/Analysis/Support
parent37e58d104d7756f7c18f525b74e46b8eeec8ef81 (diff)
Fixed bug where intrusive_ptr_add_ref and intrusive_ptr_release were
not declared "static inline." Removed member templates for operator= and copy constructor. They simply didn't work as expected. Fixed reference counting bug when a smart pointer is assigned the value of another smart pointer that refers to the same address. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42562 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Analysis/Support')
-rw-r--r--include/clang/Analysis/Support/IntrusiveSPtr.h18
1 files changed, 7 insertions, 11 deletions
diff --git a/include/clang/Analysis/Support/IntrusiveSPtr.h b/include/clang/Analysis/Support/IntrusiveSPtr.h
index 100e3dee9b..4c0322ef8a 100644
--- a/include/clang/Analysis/Support/IntrusiveSPtr.h
+++ b/include/clang/Analysis/Support/IntrusiveSPtr.h
@@ -64,11 +64,11 @@ protected:
/// particular naming was chosen to be compatible with
/// boost::intrusive_ptr, which provides similar functionality to
/// IntrusiveSPtr.
-void intrusive_ptr_add_ref(clang::RefCounted* p) { p->Retain(); }
+static inline void intrusive_ptr_add_ref(clang::RefCounted* p) { p->Retain(); }
/// intrusive_ptr_release - The complement of intrusive_ptr_add_ref;
/// decrements the reference count of a RefCounted object.
-void intrusive_ptr_release(clang::RefCounted* p) { p->Release(); }
+static inline void intrusive_ptr_release(clang::RefCounted* p) { p->Release(); }
namespace clang {
@@ -97,14 +97,7 @@ public:
retain();
}
- template <typename X>
- IntrusiveSPtr(const IntrusiveSPtr<X>& S) {
- Obj = static_cast<T*>(const_cast<X*>(S.getPtr()));
- retain();
- }
-
- template <typename X>
- IntrusiveSPtr& operator=(const IntrusiveSPtr<X>& S) {
+ IntrusiveSPtr& operator=(const IntrusiveSPtr& S) {
replace(static_cast<const T*>(S.getPtr()));
return *this;
}
@@ -127,7 +120,10 @@ private:
void retain() { if (Obj) intrusive_ptr_add_ref(Obj); }
void release() { if (Obj) intrusive_ptr_release(Obj); }
- void replace(const T* o) {
+ void replace(const T* o) {
+ if (o == Obj)
+ return;
+
release();
Obj = const_cast<T*>(o);
retain();