[llvm] r206152 - [Allocator] Hoist the external helper function into a namespace scope

Chandler Carruth chandlerc at gmail.com
Sun Apr 13 23:42:56 PDT 2014


Author: chandlerc
Date: Mon Apr 14 01:42:56 2014
New Revision: 206152

URL: http://llvm.org/viewvc/llvm-project?rev=206152&view=rev
Log:
[Allocator] Hoist the external helper function into a namespace scope
declaration. GCC 4.7 appears to get hopelessly confused by declaring
this function within a member function of a class template. Go figure.

Modified:
    llvm/trunk/include/llvm/Support/Allocator.h
    llvm/trunk/lib/Support/Allocator.cpp

Modified: llvm/trunk/include/llvm/Support/Allocator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Allocator.h?rev=206152&r1=206151&r2=206152&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Allocator.h (original)
+++ llvm/trunk/include/llvm/Support/Allocator.h Mon Apr 14 01:42:56 2014
@@ -67,6 +67,14 @@ public:
   void Deallocate(void *Slab, size_t Size) { Allocator.Deallocate(Slab); }
 };
 
+namespace detail {
+
+// We call out to an external function to actually print the message as the
+// printing code uses Allocator.h in its implementation.
+void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated,
+                                size_t TotalMemory);
+} // End namespace detail.
+
 /// \brief Allocate memory in an ever growing pool, as if by bump-pointer.
 ///
 /// This isn't strictly a bump-pointer allocator as it uses backing slabs of
@@ -200,12 +208,8 @@ public:
   }
 
   void PrintStats() const {
-    // We call out to an external function to actually print the message as the
-    // printing code uses Allocator.h in its implementation.
-    extern void printBumpPtrAllocatorStats(
-        unsigned NumSlabs, size_t BytesAllocated, size_t TotalMemory);
-
-    printBumpPtrAllocatorStats(Slabs.size(), BytesAllocated, getTotalMemory());
+    detail::printBumpPtrAllocatorStats(Slabs.size(), BytesAllocated,
+                                       getTotalMemory());
   }
 
 private:

Modified: llvm/trunk/lib/Support/Allocator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Allocator.cpp?rev=206152&r1=206151&r2=206152&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Allocator.cpp (original)
+++ llvm/trunk/lib/Support/Allocator.cpp Mon Apr 14 01:42:56 2014
@@ -21,6 +21,8 @@
 
 namespace llvm {
 
+namespace detail {
+
 void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated,
                                 size_t TotalMemory) {
   errs() << "\nNumber of memory regions: " << NumSlabs << '\n'
@@ -30,6 +32,8 @@ void printBumpPtrAllocatorStats(unsigned
          << " (includes alignment, etc)\n";
 }
 
+} // End namespace detail.
+
 void PrintRecyclerStats(size_t Size,
                         size_t Align,
                         size_t FreeListSize) {





More information about the llvm-commits mailing list