From e9fe0714ad422c2b9250c8ce13d3b2837dff5430 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 30 Mar 2017 15:39:47 -0400 Subject: DRTVWR-418: Xcode 8.3 complains about LLSafeHandle implementation. The previous LLSafeHandle implementation declares a static data member of the template class but provides no (generic) definition, relying on particular specializations to provide the definition. The data member is a function pointer, which is called in one of the methods to produce a pointer to a "null" T instance: that is, a dummy instance to be dereferenced in case the wrapped T* is null. Xcode 8.3's version of clang is bothered by the call, in a generic method, through this (usually) uninitialized pointer. It happens that the only specializations of LLSafeHandle do both provide definitions. I don't know whether that's formally valid C++03 or not; but I agree with the compiler: I don't like it. Instead of declaring a public static function pointer which each specialization is required to define, add a protected static method to the template class. This protected static method simply returns a pointer to a function-static T instance. This is functionally similar to a static LLPointer set on demand (as in the two specializations), including lazy instantiation. Unlike the previous implementation, this approach prohibits a given specialization from customizing the "null" instance function. Although there exist reasonable ways to support that (e.g. a related traits template), I decided not to complicate the LLSafeHandle implementation to make it more generally useful. I don't really approve of LLSafeHandle, and don't want to see it proliferate. It's not clear that unconditionally dereferencing LLSafeHandle is in any way better than conditionally dereferencing LLPointer. It doesn't even skip the runtime conditional test; it simply obscures it. (There exist hints in the code that at one time it might have immediately replaced any wrapped null pointer value with the pointer to the "null" instance, obviating the test at dereference time, but this is not the current functionality. Perhaps it was only ever wishful thinking.) Remove the corresponding functions and static LLPointers from the two classes that use LLSafeHandle. --- indra/newview/llparcelselection.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'indra/newview/llparcelselection.h') diff --git a/indra/newview/llparcelselection.h b/indra/newview/llparcelselection.h index 1cbdfc6f74..06d9141efb 100644 --- a/indra/newview/llparcelselection.h +++ b/indra/newview/llparcelselection.h @@ -35,6 +35,7 @@ class LLParcel; class LLParcelSelection : public LLRefCount { friend class LLViewerParcelMgr; + friend class LLSafeHandle; protected: ~LLParcelSelection(); @@ -61,8 +62,6 @@ public: // Is the entire parcel selected, or just a part? BOOL getWholeParcelSelected() const; - static LLParcelSelection* getNullParcelSelection(); - private: void setParcel(LLParcel* parcel) { mParcel = parcel; } @@ -73,8 +72,6 @@ private: S32 mSelectedSelfCount; S32 mSelectedOtherCount; S32 mSelectedPublicCount; - - static LLPointer sNullSelection; }; typedef LLSafeHandle LLParcelSelectionHandle; -- cgit v1.2.3