[Lldb-commits] [lldb] r190062 - Use <atomic> instead of "llvm/Support/Atomic.h". Removed unused RefCounter class.

Virgile Bello virgile.bello at gmail.com
Thu Sep 5 09:38:02 PDT 2013


Author: xen2
Date: Thu Sep  5 11:38:02 2013
New Revision: 190062

URL: http://llvm.org/viewvc/llvm-project?rev=190062&view=rev
Log:
Use <atomic> instead of "llvm/Support/Atomic.h". Removed unused RefCounter class.

Removed:
    lldb/trunk/include/lldb/Utility/RefCounter.h
    lldb/trunk/source/Utility/RefCounter.cpp
Modified:
    lldb/trunk/include/lldb/DataFormatters/FormatManager.h
    lldb/trunk/include/lldb/Utility/SharingPtr.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Utility/CMakeLists.txt

Modified: lldb/trunk/include/lldb/DataFormatters/FormatManager.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormatManager.h?rev=190062&r1=190061&r2=190062&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormatManager.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormatManager.h Thu Sep  5 11:38:02 2013
@@ -12,6 +12,7 @@
 
 // C Includes
 // C++ Includes
+#include <atomic>
 
 // Other libraries and framework includes
 // Project includes
@@ -23,8 +24,6 @@
 #include "lldb/DataFormatters/TypeCategory.h"
 #include "lldb/DataFormatters/TypeCategoryMap.h"
 
-#include "llvm/Support/Atomic.h"
-
 namespace lldb_private {
     
 // this file (and its. cpp) contain the low-level implementation of LLDB Data Visualization
@@ -193,7 +192,7 @@ public:
     void
     Changed ()
     {
-        llvm::sys::AtomicIncrement(&m_last_revision);
+        m_last_revision.fetch_add(1);
         m_format_cache.Clear ();
     }
     
@@ -211,7 +210,7 @@ private:
     FormatCache m_format_cache;
     ValueNavigator m_value_nav;
     NamedSummariesMap m_named_summaries_map;
-    llvm::sys::cas_flag m_last_revision;
+    std::atomic<uint32_t> m_last_revision;
     TypeCategoryMap m_categories_map;
     
     ConstString m_default_category_name;

Removed: lldb/trunk/include/lldb/Utility/RefCounter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/RefCounter.h?rev=190061&view=auto
==============================================================================
--- lldb/trunk/include/lldb/Utility/RefCounter.h (original)
+++ lldb/trunk/include/lldb/Utility/RefCounter.h (removed)
@@ -1,57 +0,0 @@
-//===-- RefCounter.h --------------------------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_RefCounter_h_
-#define liblldb_RefCounter_h_
-
-#include "lldb/lldb-public.h"
-#include "llvm/Support/Atomic.h"
-
-namespace lldb_utility {
-
-//----------------------------------------------------------------------
-// A simple reference counter object. You need an uint32_t* to use it
-// Once that is in place, everyone who needs to ref-count, can say
-// RefCounter ref(ptr);
-// (of course, the pointer is a shared resource, and must be accessible to
-// everyone who needs it). Synchronization is handled by RefCounter itself
-// The counter is decreased each time a RefCounter to it goes out of scope
-//----------------------------------------------------------------------
-class RefCounter
-{
-public:
-    typedef uint32_t value_type;
-    
-    RefCounter(value_type* ctr);
-    
-    ~RefCounter();
-    
-private:
-    value_type* m_counter;
-    DISALLOW_COPY_AND_ASSIGN (RefCounter);
-    
-    template <class T>
-    inline T
-    increment(T* t)
-    {
-        return llvm::sys::AtomicIncrement((llvm::sys::cas_flag*)&t);
-    }
-    
-    template <class T>
-    inline T
-    decrement(T* t)
-    {
-        return llvm::sys::AtomicDecrement((llvm::sys::cas_flag*)&t);
-    }
-    
-};
-
-} // namespace lldb_utility
-
-#endif // #ifndef liblldb_RefCounter_h_

Modified: lldb/trunk/include/lldb/Utility/SharingPtr.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/SharingPtr.h?rev=190062&r1=190061&r2=190062&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/SharingPtr.h (original)
+++ lldb/trunk/include/lldb/Utility/SharingPtr.h Thu Sep  5 11:38:02 2013
@@ -12,7 +12,7 @@
 
 #include <algorithm>
 #include <memory>
-#include "llvm/Support/Atomic.h"
+#include <atomic>
 
 //#define ENABLE_SP_LOGGING 1 // DON'T CHECK THIS LINE IN UNLESS COMMENTED OUT
 #if defined (ENABLE_SP_LOGGING)
@@ -27,16 +27,16 @@ namespace imp {
     
 template <class T>
 inline T
-increment(T& t)
+increment(std::atomic<T>& t)
 {
-    return llvm::sys::AtomicIncrement((llvm::sys::cas_flag*)&t);
+    return t.fetch_add(1);
 }
 
 template <class T>
 inline T
-decrement(T& t)
+decrement(std::atomic<T>& t)
 {
-    return llvm::sys::AtomicDecrement((llvm::sys::cas_flag*)&t);
+    return t.fetch_sub(1);
 }
 
 class shared_count
@@ -45,7 +45,7 @@ class shared_count
     shared_count& operator=(const shared_count&);
 
 protected:
-    long shared_owners_;
+    std::atomic<long> shared_owners_;
     virtual ~shared_count();
 private:
     virtual void on_zero_shared() = 0;
@@ -580,7 +580,7 @@ public:
     }
     
 protected:
-    long shared_owners_;
+    std::atomic<long> shared_owners_;
    
     friend class IntrusiveSharingPtr<T>;
     

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=190062&r1=190061&r2=190062&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Sep  5 11:38:02 2013
@@ -536,7 +536,6 @@
 		945E8D80152F6AB40019BCCD /* StreamGDBRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 945E8D7F152F6AB40019BCCD /* StreamGDBRemote.cpp */; };
 		9452573A16262D0200325455 /* SBDeclaration.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9452573916262D0200325455 /* SBDeclaration.cpp */; };
 		9456F2241616671900656F91 /* DynamicLibrary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9456F2211616644B00656F91 /* DynamicLibrary.cpp */; };
-		94611EB213CCA4A4003A22AF /* RefCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 94611EB113CCA4A4003A22AF /* RefCounter.cpp */; };
 		9461569A14E358A6003A195C /* SBTypeFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568A14E35621003A195C /* SBTypeFilter.cpp */; };
 		9461569B14E358A6003A195C /* SBTypeFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568B14E35621003A195C /* SBTypeFormat.cpp */; };
 		9461569C14E358A6003A195C /* SBTypeSummary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9461568C14E35621003A195C /* SBTypeSummary.cpp */; };
@@ -1583,8 +1582,6 @@
 		9452573916262D0200325455 /* SBDeclaration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBDeclaration.cpp; path = source/API/SBDeclaration.cpp; sourceTree = "<group>"; };
 		9456F2211616644B00656F91 /* DynamicLibrary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicLibrary.cpp; sourceTree = "<group>"; };
 		9456F2231616645A00656F91 /* DynamicLibrary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DynamicLibrary.h; path = include/lldb/Host/DynamicLibrary.h; sourceTree = "<group>"; };
-		94611EAF13CCA363003A22AF /* RefCounter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RefCounter.h; path = include/lldb/Utility/RefCounter.h; sourceTree = "<group>"; };
-		94611EB113CCA4A4003A22AF /* RefCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RefCounter.cpp; path = source/Utility/RefCounter.cpp; sourceTree = "<group>"; };
 		9461568614E355F2003A195C /* SBTypeFilter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeFilter.h; path = include/lldb/API/SBTypeFilter.h; sourceTree = "<group>"; };
 		9461568714E355F2003A195C /* SBTypeFormat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeFormat.h; path = include/lldb/API/SBTypeFormat.h; sourceTree = "<group>"; };
 		9461568814E355F2003A195C /* SBTypeSummary.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SBTypeSummary.h; path = include/lldb/API/SBTypeSummary.h; sourceTree = "<group>"; };
@@ -2417,8 +2414,6 @@
 				94031A9F13CF5B3D00DCFF3C /* PriorityPointerPair.h */,
 				2682F16B115EDA0D00CCFF99 /* PseudoTerminal.h */,
 				2682F16A115EDA0D00CCFF99 /* PseudoTerminal.cpp */,
-				94611EAF13CCA363003A22AF /* RefCounter.h */,
-				94611EB113CCA4A4003A22AF /* RefCounter.cpp */,
 				261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */,
 				4C2FAE2E135E3A70001EDE44 /* SharedCluster.h */,
 				261B5A5311C3F2AD00AABD0A /* SharingPtr.h */,
@@ -4312,7 +4307,6 @@
 				9463D4CD13B1798800C230D4 /* CommandObjectType.cpp in Sources */,
 				49D8FB3913B5598F00411094 /* ClangASTImporter.cpp in Sources */,
 				26ED3D6D13C563810017D45E /* OptionGroupVariable.cpp in Sources */,
-				94611EB213CCA4A4003A22AF /* RefCounter.cpp in Sources */,
 				94031A9E13CF486700DCFF3C /* InputReaderEZ.cpp in Sources */,
 				2642FBAE13D003B400ED6808 /* CommunicationKDP.cpp in Sources */,
 				2642FBB013D003B400ED6808 /* ProcessKDP.cpp in Sources */,

Modified: lldb/trunk/source/Utility/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/CMakeLists.txt?rev=190062&r1=190061&r2=190062&view=diff
==============================================================================
--- lldb/trunk/source/Utility/CMakeLists.txt (original)
+++ lldb/trunk/source/Utility/CMakeLists.txt Thu Sep  5 11:38:02 2013
@@ -5,7 +5,6 @@ add_lldb_library(lldbUtility
   KQueue.cpp
   PseudoTerminal.cpp
   Range.cpp
-  RefCounter.cpp
   SharingPtr.cpp
   StringExtractor.cpp
   StringExtractorGDBRemote.cpp

Removed: lldb/trunk/source/Utility/RefCounter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/RefCounter.cpp?rev=190061&view=auto
==============================================================================
--- lldb/trunk/source/Utility/RefCounter.cpp (original)
+++ lldb/trunk/source/Utility/RefCounter.cpp (removed)
@@ -1,25 +0,0 @@
-//===---------------------RefCounter.cpp ------------------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Utility/RefCounter.h"
-
-namespace lldb_utility {
-
-RefCounter::RefCounter(RefCounter::value_type* ctr):
-m_counter(ctr)
-{
-    increment(m_counter);
-}
-
-RefCounter::~RefCounter()
-{
-    decrement(m_counter);
-}
-
-} // namespace lldb_utility





More information about the lldb-commits mailing list