[Allocator] Hoist the external helper function into a namespace scope
authorChandler Carruth <chandlerc@gmail.com>
Mon, 14 Apr 2014 06:42:56 +0000 (06:42 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Mon, 14 Apr 2014 06:42:56 +0000 (06:42 +0000)
declaration. GCC 4.7 appears to get hopelessly confused by declaring
this function within a member function of a class template. Go figure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206152 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/Allocator.h
lib/Support/Allocator.cpp

index 4a5e1b32a50019d27e30baace8478d3f6f4c876c..19ef4e834a539b384ee8808790ae738d92d58175 100644 (file)
@@ -67,6 +67,14 @@ public:
   void Deallocate(void *Slab, size_t Size) { Allocator.Deallocate(Slab); }
 };
 
   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
 /// \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 {
   }
 
   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:
   }
 
 private:
index ae861c8c4b60a67ef0305e61955249e79c30aa48..7c306b2370e6c30fc3e03ee6dd2ac697c228a42e 100644 (file)
@@ -21,6 +21,8 @@
 
 namespace llvm {
 
 
 namespace llvm {
 
+namespace detail {
+
 void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated,
                                 size_t TotalMemory) {
   errs() << "\nNumber of memory regions: " << NumSlabs << '\n'
 void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated,
                                 size_t TotalMemory) {
   errs() << "\nNumber of memory regions: " << NumSlabs << '\n'
@@ -30,6 +32,8 @@ void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated,
          << " (includes alignment, etc)\n";
 }
 
          << " (includes alignment, etc)\n";
 }
 
+} // End namespace detail.
+
 void PrintRecyclerStats(size_t Size,
                         size_t Align,
                         size_t FreeListSize) {
 void PrintRecyclerStats(size_t Size,
                         size_t Align,
                         size_t FreeListSize) {