Defeat Clang's enhanced -Wself-assign warning

In 329493, Clang's -Wself-assign warning started also firing on
overloaded assignment operators. The suggested way to suppress it is to
use *& on the right-hand side.

This fixes the instances that fire during a debug build on Linux.

TBR=jochen

Bug: 830338
Change-Id: I5198ff8171462b78d55b84f58358588caf3f7fa2
Reviewed-on: https://chromium-review.googlesource.com/1000856
Commit-Queue: Hans Wennborg <[email protected]>
Reviewed-by: Nico Weber <[email protected]>
Cr-Commit-Position: refs/heads/master@{#549152}
diff --git a/base/containers/circular_deque_unittest.cc b/base/containers/circular_deque_unittest.cc
index df960c3..0c168e0 100644
--- a/base/containers/circular_deque_unittest.cc
+++ b/base/containers/circular_deque_unittest.cc
@@ -165,7 +165,7 @@
 // Tests that self-assignment is a no-op.
 TEST(CircularDeque, EqualsSelf) {
   circular_deque<int> q = {1, 2, 3, 4, 5, 6};
-  q = q;
+  q = *&q;  // The *& defeats Clang's -Wself-assign warning.
   EXPECT_EQ(6u, q.size());
   for (int i = 0; i < 6; i++)
     EXPECT_EQ(i + 1, q[i]);
diff --git a/base/memory/linked_ptr_unittest.cc b/base/memory/linked_ptr_unittest.cc
index 7e0c9e3..344ffa4 100644
--- a/base/memory/linked_ptr_unittest.cc
+++ b/base/memory/linked_ptr_unittest.cc
@@ -34,7 +34,7 @@
 TEST(LinkedPtrTest, Test) {
   {
     linked_ptr<A> a0, a1, a2;
-    a0 = a0;
+    a0 = *&a0;  // The *& defeats Clang's -Wself-assign warning.
     a1 = a2;
     ASSERT_EQ(a0.get(), static_cast<A*>(nullptr));
     ASSERT_EQ(a1.get(), static_cast<A*>(nullptr));
diff --git a/base/memory/ref_counted_unittest.cc b/base/memory/ref_counted_unittest.cc
index 71e75bce..d88fc540 100644
--- a/base/memory/ref_counted_unittest.cc
+++ b/base/memory/ref_counted_unittest.cc
@@ -159,7 +159,7 @@
 TEST(RefCountedUnitTest, TestSelfAssignment) {
   SelfAssign* p = new SelfAssign;
   scoped_refptr<SelfAssign> var(p);
-  var = var;
+  var = *&var;  // The *& defeats Clang's -Wself-assign warning.
   EXPECT_EQ(var.get(), p);
   var = std::move(var);
   EXPECT_EQ(var.get(), p);
diff --git a/base/observer_list_unittest.cc b/base/observer_list_unittest.cc
index 8575bc7..010ee9c 100644
--- a/base/observer_list_unittest.cc
+++ b/base/observer_list_unittest.cc
@@ -211,7 +211,7 @@
     EXPECT_EQ(it3, it1);
     EXPECT_EQ(it3, it2);
     // Self assignment.
-    it3 = it3;
+    it3 = *&it3;  // The *& defeats Clang's -Wself-assign warning.
     EXPECT_EQ(it3, it1);
     EXPECT_EQ(it3, it2);
   }
@@ -228,7 +228,7 @@
     EXPECT_EQ(it3, it1);
     EXPECT_EQ(it3, it2);
     // Self assignment.
-    it3 = it3;
+    it3 = *&it3;  // The *& defeats Clang's -Wself-assign warning.
     EXPECT_EQ(it3, it1);
     EXPECT_EQ(it3, it2);
   }
@@ -255,7 +255,7 @@
     EXPECT_EQ(it3, it1);
     EXPECT_EQ(it3, it2);
     // Self assignment.
-    it3 = it3;
+    it3 = *&it3;  // The *& defeats Clang's -Wself-assign warning.
     EXPECT_EQ(it3, it1);
     EXPECT_EQ(it3, it2);
     // Iterator post increment.
@@ -278,7 +278,7 @@
     EXPECT_EQ(it3, it1);
     EXPECT_EQ(it3, it2);
     // Self assignment.
-    it3 = it3;
+    it3 = *&it3;  // The *& defeats Clang's -Wself-assign warning.
     EXPECT_EQ(it3, it1);
     EXPECT_EQ(it3, it2);
     // Iterator post increment.
diff --git a/components/autofill/core/browser/autofill_profile_unittest.cc b/components/autofill/core/browser/autofill_profile_unittest.cc
index 33259eb..22934f9 100644
--- a/components/autofill/core/browser/autofill_profile_unittest.cc
+++ b/components/autofill/core/browser/autofill_profile_unittest.cc
@@ -809,7 +809,7 @@
   EXPECT_TRUE(a == b);
 
   // Assignment to self should not change the profile value.
-  a = a;
+  a = *&a;  // The *& defeats Clang's -Wself-assign warning.
   EXPECT_TRUE(a == b);
 }
 
diff --git a/components/autofill/core/browser/credit_card_unittest.cc b/components/autofill/core/browser/credit_card_unittest.cc
index 99b28bf0..19fd6a2 100644
--- a/components/autofill/core/browser/credit_card_unittest.cc
+++ b/components/autofill/core/browser/credit_card_unittest.cc
@@ -242,7 +242,7 @@
   EXPECT_TRUE(a == b);
 
   // Assignment to self should not change the profile value.
-  a = a;
+  a = *&a;  // The *& defeats Clang's -Wself-assign warning.
   EXPECT_TRUE(a == b);
 }
 
diff --git a/ppapi/tests/test_var.cc b/ppapi/tests/test_var.cc
index 08fc833..b127e43 100644
--- a/ppapi/tests/test_var.cc
+++ b/ppapi/tests/test_var.cc
@@ -65,7 +65,7 @@
   // Make sure we can assign a C++ object to itself and it stays alive.
   {
     pp::Var a("test");
-    a = a;
+    a = *&a;  // The *& defeats Clang's -Wself-assign warning.
     ASSERT_TRUE(a.AsString() == "test");
   }
 
diff --git a/url/gurl_unittest.cc b/url/gurl_unittest.cc
index 517c83c..eefa736 100644
--- a/url/gurl_unittest.cc
+++ b/url/gurl_unittest.cc
@@ -187,7 +187,7 @@
 TEST(GURLTest, SelfAssign) {
   GURL a("filesystem:http://example.com/temporary/");
   // This should not crash.
-  a = a;
+  a = *&a;  // The *& defeats Clang's -Wself-assign warning.
 }
 
 TEST(GURLTest, CopyFileSystem) {