Skip to content

Commit b8966de

Browse files
committed
[lldb] Remove some dead code from SharingPtr.h
These classes are not used.
1 parent df71000 commit b8966de

File tree

1 file changed

+0
-245
lines changed

1 file changed

+0
-245
lines changed

lldb/include/lldb/Utility/SharingPtr.h

Lines changed: 0 additions & 245 deletions
Original file line numberDiff line numberDiff line change
@@ -359,251 +359,6 @@ SharingPtr<T> const_pointer_cast(const SharingPtr<U> &r) {
359359
return SharingPtr<T>(r, const_cast<T *>(r.get()));
360360
}
361361

362-
template <class T> class LoggingSharingPtr : public SharingPtr<T> {
363-
typedef SharingPtr<T> base;
364-
365-
public:
366-
typedef void (*Callback)(void *, const LoggingSharingPtr &, bool action);
367-
// action: false means increment just happened
368-
// true means decrement is about to happen
369-
370-
LoggingSharingPtr() : cb_(0), baton_(nullptr) {}
371-
372-
LoggingSharingPtr(Callback cb, void *baton) : cb_(cb), baton_(baton) {
373-
if (cb_)
374-
cb_(baton_, *this, false);
375-
}
376-
377-
template <class Y>
378-
LoggingSharingPtr(Y *p) : base(p), cb_(0), baton_(nullptr) {}
379-
380-
template <class Y>
381-
LoggingSharingPtr(Y *p, Callback cb, void *baton)
382-
: base(p), cb_(cb), baton_(baton) {
383-
if (cb_)
384-
cb_(baton_, *this, false);
385-
}
386-
387-
~LoggingSharingPtr() {
388-
if (cb_)
389-
cb_(baton_, *this, true);
390-
}
391-
392-
LoggingSharingPtr(const LoggingSharingPtr &p)
393-
: base(p), cb_(p.cb_), baton_(p.baton_) {
394-
if (cb_)
395-
cb_(baton_, *this, false);
396-
}
397-
398-
LoggingSharingPtr &operator=(const LoggingSharingPtr &p) {
399-
if (cb_)
400-
cb_(baton_, *this, true);
401-
base::operator=(p);
402-
cb_ = p.cb_;
403-
baton_ = p.baton_;
404-
if (cb_)
405-
cb_(baton_, *this, false);
406-
return *this;
407-
}
408-
409-
void reset() {
410-
if (cb_)
411-
cb_(baton_, *this, true);
412-
base::reset();
413-
}
414-
415-
template <class Y> void reset(Y *p) {
416-
if (cb_)
417-
cb_(baton_, *this, true);
418-
base::reset(p);
419-
if (cb_)
420-
cb_(baton_, *this, false);
421-
}
422-
423-
void SetCallback(Callback cb, void *baton) {
424-
cb_ = cb;
425-
baton_ = baton;
426-
}
427-
428-
void ClearCallback() {
429-
cb_ = 0;
430-
baton_ = 0;
431-
}
432-
433-
private:
434-
Callback cb_;
435-
void *baton_;
436-
};
437-
438-
template <class T> class IntrusiveSharingPtr;
439-
440-
template <class T> class ReferenceCountedBase {
441-
public:
442-
explicit ReferenceCountedBase() : shared_owners_(-1) {}
443-
444-
void add_shared();
445-
446-
void release_shared();
447-
448-
long use_count() const { return shared_owners_ + 1; }
449-
450-
protected:
451-
long shared_owners_;
452-
453-
friend class IntrusiveSharingPtr<T>;
454-
455-
private:
456-
ReferenceCountedBase(const ReferenceCountedBase &) = delete;
457-
ReferenceCountedBase &operator=(const ReferenceCountedBase &) = delete;
458-
};
459-
460-
template <class T> void lldb_private::ReferenceCountedBase<T>::add_shared() {
461-
#ifdef _MSC_VER
462-
_InterlockedIncrement(&shared_owners_);
463-
#else
464-
++shared_owners_;
465-
#endif
466-
}
467-
468-
template <class T>
469-
void lldb_private::ReferenceCountedBase<T>::release_shared() {
470-
#ifdef _MSC_VER
471-
if (_InterlockedDecrement(&shared_owners_) == -1)
472-
#else
473-
if (--shared_owners_ == -1)
474-
#endif
475-
delete static_cast<T *>(this);
476-
}
477-
478-
template <class T>
479-
class ReferenceCountedBaseVirtual : public imp::shared_count {
480-
public:
481-
explicit ReferenceCountedBaseVirtual() : imp::shared_count(-1) {}
482-
483-
~ReferenceCountedBaseVirtual() override = default;
484-
485-
void on_zero_shared() override;
486-
};
487-
488-
template <class T> void ReferenceCountedBaseVirtual<T>::on_zero_shared() {}
489-
490-
template <typename T> class IntrusiveSharingPtr {
491-
public:
492-
typedef T element_type;
493-
494-
explicit IntrusiveSharingPtr() : ptr_(0) {}
495-
496-
explicit IntrusiveSharingPtr(T *ptr) : ptr_(ptr) { add_shared(); }
497-
498-
IntrusiveSharingPtr(const IntrusiveSharingPtr &rhs) : ptr_(rhs.ptr_) {
499-
add_shared();
500-
}
501-
502-
template <class X>
503-
IntrusiveSharingPtr(const IntrusiveSharingPtr<X> &rhs) : ptr_(rhs.get()) {
504-
add_shared();
505-
}
506-
507-
IntrusiveSharingPtr &operator=(const IntrusiveSharingPtr &rhs) {
508-
reset(rhs.get());
509-
return *this;
510-
}
511-
512-
template <class X>
513-
IntrusiveSharingPtr &operator=(const IntrusiveSharingPtr<X> &rhs) {
514-
reset(rhs.get());
515-
return *this;
516-
}
517-
518-
IntrusiveSharingPtr &operator=(T *ptr) {
519-
reset(ptr);
520-
return *this;
521-
}
522-
523-
~IntrusiveSharingPtr() {
524-
release_shared();
525-
ptr_ = nullptr;
526-
}
527-
528-
T &operator*() const { return *ptr_; }
529-
530-
T *operator->() const { return ptr_; }
531-
532-
T *get() const { return ptr_; }
533-
534-
explicit operator bool() const { return ptr_ != 0; }
535-
536-
void swap(IntrusiveSharingPtr &rhs) {
537-
std::swap(ptr_, rhs.ptr_);
538-
#if defined(ENABLE_SP_LOGGING)
539-
track_sp(this, ptr_, use_count());
540-
track_sp(&rhs, rhs.ptr_, rhs.use_count());
541-
#endif
542-
}
543-
544-
void reset(T *ptr = nullptr) { IntrusiveSharingPtr(ptr).swap(*this); }
545-
546-
long use_count() const {
547-
if (ptr_)
548-
return ptr_->use_count();
549-
return 0;
550-
}
551-
552-
bool unique() const { return use_count() == 1; }
553-
554-
private:
555-
element_type *ptr_;
556-
557-
void add_shared() {
558-
if (ptr_) {
559-
ptr_->add_shared();
560-
#if defined(ENABLE_SP_LOGGING)
561-
track_sp(this, ptr_, ptr_->use_count());
562-
#endif
563-
}
564-
}
565-
void release_shared() {
566-
if (ptr_) {
567-
#if defined(ENABLE_SP_LOGGING)
568-
track_sp(this, nullptr, ptr_->use_count() - 1);
569-
#endif
570-
ptr_->release_shared();
571-
}
572-
}
573-
};
574-
575-
template <class T, class U>
576-
inline bool operator==(const IntrusiveSharingPtr<T> &lhs,
577-
const IntrusiveSharingPtr<U> &rhs) {
578-
return lhs.get() == rhs.get();
579-
}
580-
581-
template <class T, class U>
582-
inline bool operator!=(const IntrusiveSharingPtr<T> &lhs,
583-
const IntrusiveSharingPtr<U> &rhs) {
584-
return lhs.get() != rhs.get();
585-
}
586-
587-
template <class T, class U>
588-
inline bool operator==(const IntrusiveSharingPtr<T> &lhs, U *rhs) {
589-
return lhs.get() == rhs;
590-
}
591-
592-
template <class T, class U>
593-
inline bool operator!=(const IntrusiveSharingPtr<T> &lhs, U *rhs) {
594-
return lhs.get() != rhs;
595-
}
596-
597-
template <class T, class U>
598-
inline bool operator==(T *lhs, const IntrusiveSharingPtr<U> &rhs) {
599-
return lhs == rhs.get();
600-
}
601-
602-
template <class T, class U>
603-
inline bool operator!=(T *lhs, const IntrusiveSharingPtr<U> &rhs) {
604-
return lhs != rhs.get();
605-
}
606-
607362
} // namespace lldb_private
608363

609364
#endif // utility_SharingPtr_h_

0 commit comments

Comments
 (0)