Bug 1322458 - Fix kungFuDeathGrip errors that clang plugin reports on Windows. r?ehsan draft bug-1322458
authorTing-Yu Chou <janus926@gmail.com>
Wed, 14 Dec 2016 16:34:12 +0800
changeset 449789 5be08f3efac03986a284eaa7a77a19f37d497c6b
parent 448717 f46f85dcfbc2b3098ea758825d18be6fab33cbc6
child 539575 2b5c44d88336cf683e69210e9758c732d5b421c0
push id38661
push userbmo:janus926@gmail.com
push dateThu, 15 Dec 2016 03:13:32 +0000
reviewersehsan
bugs1322458
milestone53.0a1
Bug 1322458 - Fix kungFuDeathGrip errors that clang plugin reports on Windows. r?ehsan MozReview-Commit-ID: FLTLZSg2yh9
gfx/layers/d3d9/CompositorD3D9.cpp
ipc/mscom/EnsureMTA.h
ipc/mscom/WeakRef.cpp
widget/windows/TSFTextStore.cpp
--- a/gfx/layers/d3d9/CompositorD3D9.cpp
+++ b/gfx/layers/d3d9/CompositorD3D9.cpp
@@ -210,16 +210,17 @@ CompositorD3D9::CreateRenderTargetFromSo
                                                     aRect);
 }
 
 void
 CompositorD3D9::SetRenderTarget(CompositingRenderTarget *aRenderTarget)
 {
   MOZ_ASSERT(aRenderTarget && mDeviceManager);
   RefPtr<CompositingRenderTargetD3D9> oldRT = mCurrentRT;
+  Unused << oldRT;
   mCurrentRT = static_cast<CompositingRenderTargetD3D9*>(aRenderTarget);
   mCurrentRT->BindRenderTarget(device());
   PrepareViewport(mCurrentRT->GetSize());
 }
 
 static DeviceManagerD3D9::ShaderMode
 ShaderModeForEffectType(EffectTypes aEffectType, gfx::SurfaceFormat aFormat)
 {
--- a/ipc/mscom/EnsureMTA.h
+++ b/ipc/mscom/EnsureMTA.h
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_mscom_EnsureMTA_h
 #define mozilla_mscom_EnsureMTA_h
 
 #include "MainThreadUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/DebugOnly.h"
+#include "mozilla/Unused.h"
 #include "mozilla/mscom/COMApartmentRegion.h"
 #include "mozilla/mscom/Utils.h"
 #include "nsCOMPtr.h"
 #include "nsIThread.h"
 #include "nsThreadUtils.h"
 
 #include <windows.h>
 
@@ -28,16 +29,17 @@ public:
   /**
    * This constructor just ensures that the MTA thread is up and running.
    */
   EnsureMTA()
   {
     MOZ_ASSERT(NS_IsMainThread());
     nsCOMPtr<nsIThread> thread = GetMTAThread();
     MOZ_ASSERT(thread);
+    Unused << thread;
   }
 
   template <typename FuncT>
   EnsureMTA(const FuncT& aClosure)
   {
     MOZ_ASSERT(NS_IsMainThread());
     if (IsCurrentThreadMTA()) {
       // We're already on the MTA, we can run aClosure directly
--- a/ipc/mscom/WeakRef.cpp
+++ b/ipc/mscom/WeakRef.cpp
@@ -35,17 +35,17 @@ WeakReferenceSupport::QueryInterface(REF
   AutoCriticalSection lock(&mCS);
   RefPtr<IUnknown> punk;
   if (!ppv) {
     return E_INVALIDARG;
   }
   *ppv = nullptr;
 
   // Raise the refcount for stabilization purposes during aggregation
-  RefPtr<IUnknown> kungFuDeathGrip(static_cast<IUnknown*>(this));
+  RefPtr<IUnknown> kungFuDeathGrip(this);
 
   if (riid == IID_IUnknown || riid == IID_IWeakReferenceSource) {
     punk = static_cast<IUnknown*>(this);
   } else {
     HRESULT hr = ThreadSafeQueryInterface(riid, getter_AddRefs(punk));
     if (FAILED(hr)) {
       return hr;
     }
--- a/widget/windows/TSFTextStore.cpp
+++ b/widget/windows/TSFTextStore.cpp
@@ -1714,17 +1714,17 @@ TSFTextStore::FlushPendingActions()
     // composition with a document lock.  In such case, TSFTextStore needs to
     // behave as expected by TIP.
     mPendingActions.Clear();
     mPendingSelectionChangeData.Clear();
     mHasReturnedNoLayoutError = false;
     return;
   }
 
-  RefPtr<nsWindowBase> kungFuDeathGrip(mWidget);
+  RefPtr<nsWindowBase> widget(mWidget);
   nsresult rv = mDispatcher->BeginNativeInputTransaction();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     MOZ_LOG(sTextStoreLog, LogLevel::Error,
       ("0x%p   TSFTextStore::FlushPendingActions() "
        "FAILED due to BeginNativeInputTransaction() failure", this));
     return;
   }
   for (uint32_t i = 0; i < mPendingActions.Length(); i++) {
@@ -1743,18 +1743,18 @@ TSFTextStore::FlushPendingActions()
             ("0x%p   TSFTextStore::FlushPendingActions() "
              "IGNORED pending compositionstart due to already destroyed",
              this));
           break;
         }
 
         if (action.mAdjustSelection) {
           // Select composition range so the new composition replaces the range
-          WidgetSelectionEvent selectionSet(true, eSetSelection, mWidget);
-          mWidget->InitEvent(selectionSet);
+          WidgetSelectionEvent selectionSet(true, eSetSelection, widget);
+          widget->InitEvent(selectionSet);
           selectionSet.mOffset = static_cast<uint32_t>(action.mSelectionStart);
           selectionSet.mLength = static_cast<uint32_t>(action.mSelectionLength);
           selectionSet.mReversed = false;
           DispatchEvent(selectionSet);
           if (!selectionSet.mSucceeded) {
             MOZ_LOG(sTextStoreLog, LogLevel::Error,
               ("0x%p   TSFTextStore::FlushPendingActions() "
                "FAILED due to eSetSelection failure", this));
@@ -1765,28 +1765,28 @@ TSFTextStore::FlushPendingActions()
         // eCompositionStart always causes
         // NOTIFY_IME_OF_COMPOSITION_EVENT_HANDLED.  Therefore, we should
         // wait to clear mContentForTSF until it's notified.
         mDeferClearingContentForTSF = true;
 
         MOZ_LOG(sTextStoreLog, LogLevel::Debug,
           ("0x%p   TSFTextStore::FlushPendingActions() "
            "dispatching compositionstart event...", this));
-        WidgetEventTime eventTime = mWidget->CurrentMessageWidgetEventTime();
+        WidgetEventTime eventTime = widget->CurrentMessageWidgetEventTime();
         nsEventStatus status;
         rv = mDispatcher->StartComposition(status, &eventTime);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           MOZ_LOG(sTextStoreLog, LogLevel::Error,
             ("0x%p   TSFTextStore::FlushPendingActions() "
              "FAILED to dispatch compositionstart event, "
              "IsComposingInContent()=%s",
              this, GetBoolName(!IsComposingInContent())));
           mDeferClearingContentForTSF = !IsComposingInContent();
         }
-        if (!mWidget || mWidget->Destroyed()) {
+        if (!widget || widget->Destroyed()) {
           break;
         }
         break;
       }
       case PendingAction::COMPOSITION_UPDATE: {
         MOZ_LOG(sTextStoreLog, LogLevel::Debug,
           ("0x%p   TSFTextStore::FlushPendingActions() "
            "flushing COMPOSITION_UPDATE={ mData=\"%s\", "
@@ -1809,17 +1809,17 @@ TSFTextStore::FlushPendingActions()
              "FAILED to setting pending composition... "
              "IsComposingInContent()=%s",
              this, GetBoolName(IsComposingInContent())));
           mDeferClearingContentForTSF = !IsComposingInContent();
         } else {
           MOZ_LOG(sTextStoreLog, LogLevel::Debug,
             ("0x%p   TSFTextStore::FlushPendingActions() "
              "dispatching compositionchange event...", this));
-          WidgetEventTime eventTime = mWidget->CurrentMessageWidgetEventTime();
+          WidgetEventTime eventTime = widget->CurrentMessageWidgetEventTime();
           nsEventStatus status;
           rv = mDispatcher->FlushPendingComposition(status, &eventTime);
           if (NS_WARN_IF(NS_FAILED(rv))) {
             MOZ_LOG(sTextStoreLog, LogLevel::Error,
               ("0x%p   TSFTextStore::FlushPendingActions() "
                "FAILED to dispatch compositionchange event, "
                "IsComposingInContent()=%s",
                this, GetBoolName(IsComposingInContent())));
@@ -1839,17 +1839,17 @@ TSFTextStore::FlushPendingActions()
         // the IME will be notified of NOTIFY_IME_OF_COMPOSITION_EVENT_HANDLED.
         // In this case, we should not clear mContentForTSFuntil we notify
         // the IME of the composition update.
         mDeferClearingContentForTSF = true;
 
         MOZ_LOG(sTextStoreLog, LogLevel::Debug,
           ("0x%p   TSFTextStore::FlushPendingActions(), "
            "dispatching compositioncommit event...", this));
-        WidgetEventTime eventTime = mWidget->CurrentMessageWidgetEventTime();
+        WidgetEventTime eventTime = widget->CurrentMessageWidgetEventTime();
         nsEventStatus status;
         rv = mDispatcher->CommitComposition(status, &action.mData, &eventTime);
         if (NS_WARN_IF(NS_FAILED(rv))) {
           MOZ_LOG(sTextStoreLog, LogLevel::Error,
             ("0x%p   TSFTextStore::FlushPendingActions() "
              "FAILED to dispatch compositioncommit event, "
              "IsComposingInContent()=%s",
              this, GetBoolName(IsComposingInContent())));
@@ -1870,29 +1870,29 @@ TSFTextStore::FlushPendingActions()
         if (mDestroyed) {
           MOZ_LOG(sTextStoreLog, LogLevel::Warning,
             ("0x%p   TSFTextStore::FlushPendingActions() "
              "IGNORED pending selectionset due to already destroyed",
              this));
           break;
         }
 
-        WidgetSelectionEvent selectionSet(true, eSetSelection, mWidget);
-        selectionSet.mOffset = 
+        WidgetSelectionEvent selectionSet(true, eSetSelection, widget);
+        selectionSet.mOffset =
           static_cast<uint32_t>(action.mSelectionStart);
         selectionSet.mLength =
           static_cast<uint32_t>(action.mSelectionLength);
         selectionSet.mReversed = action.mSelectionReversed;
         break;
       }
       default:
         MOZ_CRASH("unexpected action type");
     }
 
-    if (mWidget && !mWidget->Destroyed()) {
+    if (widget && !widget->Destroyed()) {
       continue;
     }
 
     MOZ_LOG(sTextStoreLog, LogLevel::Info,
       ("0x%p   TSFTextStore::FlushPendingActions(), "
        "qutting since the mWidget has gone", this));
     break;
   }