From 8208a40412fac35593d4b8b13f43c6be5e4d6990 Mon Sep 17 00:00:00 2001
From: Richard Linden <none@none>
Date: Mon, 1 Jul 2013 18:50:51 -0700
Subject: [PATCH] BUILDFIX: reverted changes that attempted to automate mem
 track stat definition as they don't work on gcc/clang

---
 indra/llcommon/lltrace.h                   | 22 ++++++++--------------
 indra/llimage/llimage.cpp                  |  1 +
 indra/llimage/llimage.h                    |  2 ++
 indra/llimage/tests/llimageworker_test.cpp |  3 +++
 indra/llkdu/tests/llimagej2ckdu_test.cpp   |  2 ++
 indra/llui/lltextbase.cpp                  |  2 ++
 indra/llui/lltextbase.h                    |  2 ++
 indra/llui/llview.cpp                      |  1 +
 indra/llui/llview.h                        |  1 +
 indra/llui/llviewmodel.cpp                 |  2 ++
 indra/llui/llviewmodel.h                   |  2 ++
 indra/newview/lldrawable.cpp               |  1 +
 indra/newview/lldrawable.h                 |  1 +
 indra/newview/llviewerobject.cpp           |  2 ++
 indra/newview/llviewerobject.h             |  1 +
 indra/newview/llvocache.cpp                |  2 ++
 indra/newview/llvocache.h                  |  2 ++
 17 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index 1cde450dc25..e2c4b632764 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -336,7 +336,7 @@ class MemTrackable
 
 	void* operator new(size_t size) 
 	{
-		MemStatAccumulator* accumulator = mem_trackable_t::sMemStat.getPrimaryAccumulator();
+		MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
 		if (accumulator)
 		{
 			accumulator->mSize.sample(accumulator->mSize.getLastValue() + (F64)size);
@@ -348,7 +348,7 @@ class MemTrackable
 
 	void operator delete(void* ptr, size_t size)
 	{
-		MemStatAccumulator* accumulator = mem_trackable_t::sMemStat.getPrimaryAccumulator();
+		MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
 		if (accumulator)
 		{
 			accumulator->mSize.sample(accumulator->mSize.getLastValue() - (F64)size);
@@ -360,7 +360,7 @@ class MemTrackable
 
 	void *operator new [](size_t size)
 	{
-		MemStatAccumulator* accumulator = mem_trackable_t::sMemStat.getPrimaryAccumulator();
+		MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
 		if (accumulator)
 		{
 			accumulator->mSize.sample(accumulator->mSize.getLastValue() + (F64)size);
@@ -372,7 +372,7 @@ class MemTrackable
 
 	void operator delete[](void* ptr, size_t size)
 	{
-		MemStatAccumulator* accumulator = mem_trackable_t::sMemStat.getPrimaryAccumulator();
+		MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
 		if (accumulator)
 		{
 			accumulator->mSize.sample(accumulator->mSize.getLastValue() - (F64)size);
@@ -438,15 +438,13 @@ class MemTrackable
 
 private:
 	size_t mMemFootprint;
-	static MemStatHandle sMemStat;
-
 
 	template<typename TRACKED, typename TRACKED_IS_TRACKER = void>
 	struct TrackMemImpl
 	{
 		static void claim(mem_trackable_t& tracker, const TRACKED& tracked)
 		{
-			MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator();
+			MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
 			if (accumulator)
 			{
 				size_t footprint = MemFootprint<TRACKED>::measure(tracked);
@@ -457,7 +455,7 @@ class MemTrackable
 
 		static void disclaim(mem_trackable_t& tracker, const TRACKED& tracked)
 		{
-			MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator();
+			MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
 			if (accumulator)
 			{
 				size_t footprint = MemFootprint<TRACKED>::measure(tracked);
@@ -472,7 +470,7 @@ class MemTrackable
 	{
 		static void claim(mem_trackable_t& tracker, TRACKED& tracked)
 		{
-			MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator();
+			MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
 			if (accumulator)
 			{
 				accumulator->mChildSize.sample(accumulator->mChildSize.getLastValue() + (F64)MemFootprint<TRACKED>::measure(tracked));
@@ -481,7 +479,7 @@ class MemTrackable
 
 		static void disclaim(mem_trackable_t& tracker, TRACKED& tracked)
 		{
-			MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator();
+			MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator();
 			if (accumulator)
 			{
 				accumulator->mChildSize.sample(accumulator->mChildSize.getLastValue() - (F64)MemFootprint<TRACKED>::measure(tracked));
@@ -490,9 +488,5 @@ class MemTrackable
 	};
 };
 
-template<typename DERIVED, size_t ALIGNMENT>
-MemStatHandle MemTrackable<DERIVED, ALIGNMENT>::sMemStat(typeid(DERIVED).name());
-
-
 }
 #endif // LL_LLTRACE_H
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 395e6a6cc50..8477e62db75 100755
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -50,6 +50,7 @@ LLMutex* LLImage::sMutex = NULL;
 bool LLImage::sUseNewByteRange = false;
 S32  LLImage::sMinimalReverseByteRangePercent = 75;
 LLPrivateMemoryPool* LLImageBase::sPrivatePoolp = NULL ;
+LLTrace::MemStatHandle	LLImageBase::sMemStat("LLImage");
 
 //static
 void LLImage::initClass(bool use_new_byte_range, S32 minimal_reverse_byte_range_percent)
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index b2bfdba3f84..504b7e4795c 100755
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -165,6 +165,8 @@ class LLImageBase
 	static void destroyPrivatePool() ;
 	static LLPrivateMemoryPool* getPrivatePool() {return sPrivatePoolp;}
 
+	static LLTrace::MemStatHandle sMemStat;
+
 private:
 	U8 *mData;
 	S32 mDataSize;
diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp
index 7d7e9e036e2..aba78839749 100755
--- a/indra/llimage/tests/llimageworker_test.cpp
+++ b/indra/llimage/tests/llimageworker_test.cpp
@@ -44,6 +44,9 @@
 // * Do not make any assumption as to how those classes or methods work (i.e. don't copy/paste code)
 // * A simulator for a class can be implemented here. Please comment and document thoroughly.
 
+LLTrace::MemStatHandle	LLImageBase::sMemStat("LLImage");
+
+
 LLImageBase::LLImageBase() 
 : mData(NULL),
 mDataSize(0),
diff --git a/indra/llkdu/tests/llimagej2ckdu_test.cpp b/indra/llkdu/tests/llimagej2ckdu_test.cpp
index 0e73f33e047..14fbf344abf 100755
--- a/indra/llkdu/tests/llimagej2ckdu_test.cpp
+++ b/indra/llkdu/tests/llimagej2ckdu_test.cpp
@@ -44,6 +44,8 @@
 // End Stubbing
 // -------------------------------------------------------------------------------------------
 // Stub the LL Image Classes
+LLTrace::MemStatHandle	LLImageBase::sMemStat("LLImage");
+
 LLImageRaw::LLImageRaw() { }
 LLImageRaw::~LLImageRaw() { }
 U8* LLImageRaw::allocateData(S32 ) { return NULL; }
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 98459417780..7243931dbbd 100755
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -48,6 +48,8 @@ const F32	CURSOR_FLASH_DELAY = 1.0f;  // in seconds
 const S32	CURSOR_THICKNESS = 2;
 const F32	TRIPLE_CLICK_INTERVAL = 0.3f;	// delay between double and triple click.
 
+LLTrace::MemStatHandle	LLTextSegment::sMemStat("LLTextSegment");
+
 LLTextBase::line_info::line_info(S32 index_start, S32 index_end, LLRect rect, S32 line_num) 
 :	mDocIndexStart(index_start), 
 	mDocIndexEnd(index_end),
diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h
index 3e93b7de65b..74dc7f96931 100755
--- a/indra/llui/lltextbase.h
+++ b/indra/llui/lltextbase.h
@@ -100,6 +100,8 @@ class LLTextSegment
 	S32						getEnd() const						{ return mEnd; }
 	void					setEnd( S32 end )					{ mEnd = end; }
 
+	static LLTrace::MemStatHandle sMemStat;
+
 protected:
 	S32				mStart;
 	S32				mEnd;
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index b2805a32e85..daeb4d79399 100755
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -69,6 +69,7 @@ LLView* LLView::sPreviewClickedElement = NULL;
 BOOL	LLView::sDrawPreviewHighlights = FALSE;
 S32		LLView::sLastLeftXML = S32_MIN;
 S32		LLView::sLastBottomXML = S32_MIN;
+LLTrace::MemStatHandle	LLView::sMemStat("LLView");
 std::vector<LLViewDrawContext*> LLViewDrawContext::sDrawContextStack;
 
 LLView::DrilldownFunc LLView::sDrilldown =
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index 62bfb545664..0568fa889a3 100755
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -675,6 +675,7 @@ class LLView
 	static S32 sLastLeftXML;
 	static S32 sLastBottomXML;
 	static BOOL sForceReshape;
+	static LLTrace::MemStatHandle sMemStat;
 };
 
 namespace LLInitParam
diff --git a/indra/llui/llviewmodel.cpp b/indra/llui/llviewmodel.cpp
index dff0dcb2fd6..901260bec85 100755
--- a/indra/llui/llviewmodel.cpp
+++ b/indra/llui/llviewmodel.cpp
@@ -35,6 +35,8 @@
 // external library headers
 // other Linden headers
 
+LLTrace::MemStatHandle	LLViewModel::sMemStat("LLViewModel");
+
 ///
 LLViewModel::LLViewModel()
  : mDirty(false)
diff --git a/indra/llui/llviewmodel.h b/indra/llui/llviewmodel.h
index a2ca20c739c..2c016d25606 100755
--- a/indra/llui/llviewmodel.h
+++ b/indra/llui/llviewmodel.h
@@ -83,6 +83,8 @@ class LLViewModel
 	// 
     void setDirty() { mDirty = true; }
 
+	static LLTrace::MemStatHandle sMemStat;
+
 protected:
     LLSD mValue;
     bool mDirty;
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index 3dddf4b5545..628f7f7bfb1 100755
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -59,6 +59,7 @@ const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f;
 static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound");
 
 extern bool gShiftFrame;
+LLTrace::MemStatHandle	LLDrawable::sMemStat("LLDrawable");
 
 
 ////////////////////////
diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h
index 4558597d89b..b7c5aeb5a87 100755
--- a/indra/newview/lldrawable.h
+++ b/indra/newview/lldrawable.h
@@ -293,6 +293,7 @@ class LLDrawable
 	F32				mDistanceWRTCamera;
 
 	static F32 sCurPixelAngle; //current pixels per radian
+	static LLTrace::MemStatHandle sMemStat;
 
 private:
 	typedef std::vector<LLFace*> face_list_t;
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index c633e3acdde..4e514ddfd16 100755
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -114,6 +114,8 @@ BOOL		LLViewerObject::sMapDebug = TRUE;
 LLColor4	LLViewerObject::sEditSelectColor(	1.0f, 1.f, 0.f, 0.3f);	// Edit OK
 LLColor4	LLViewerObject::sNoEditSelectColor(	1.0f, 0.f, 0.f, 0.3f);	// Can't edit
 S32			LLViewerObject::sAxisArrowLength(50);
+LLTrace::MemStatHandle	LLViewerObject::sMemStat("LLViewerObject");
+
 
 BOOL		LLViewerObject::sPulseEnabled(FALSE);
 BOOL		LLViewerObject::sUseSharedDrawables(FALSE); // TRUE
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 63da7152b38..5556a4c7d3a 100755
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -661,6 +661,7 @@ class LLViewerObject
 	LLPointer<class LLHUDIcon> mIcon;
 
 	static			BOOL		sUseSharedDrawables;
+	static	LLTrace::MemStatHandle	sMemStat;
 
 protected:
 	// delete an item in the inventory, but don't tell the
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index d87eb5d3db9..60d78890b5f 100755
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -34,6 +34,8 @@
 #include "llviewerregion.h"
 #include "pipeline.h"
 
+LLTrace::MemStatHandle	LLVOCachePartition::sMemStat("LLVOCachePartition");
+
 BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) 
 {
 	return apr_file->read(src, n_bytes) == n_bytes ;
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index c43c42908f4..c42374e154b 100755
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -157,6 +157,8 @@ class LLVOCachePartition : public LLViewerOctreePartition, public LLTrace::MemTr
 	/*virtual*/ S32 cull(LLCamera &camera);
 	void addOccluders(LLviewerOctreeGroup* gp);
 
+	static	LLTrace::MemStatHandle	sMemStat;
+
 private:	
 	void processOccluders(LLCamera* camera, const LLVector3* region_agent);
 
-- 
GitLab