From 489158d82ae86d0b31694141d2d799bd240e14f8 Mon Sep 17 00:00:00 2001 From: Tomas Popela Date: Wed, 16 Aug 2017 12:22:55 +0000 Subject: [PATCH] Fix the compilation of LinkedHashSet with GCC Currently the compilation fails: ../../third_party/WebKit/Source/platform/wtf/LinkedHashSet.h: In member function ‘void WTF::LinkedHashSet::Swap(WTF::LinkedHashSet&)’: ../../third_party/WebKit/Source/platform/wtf/LinkedHashSet.h:691:3: error: there are no arguments to ‘SwapAnchor’ that depend on a template parameter, so a declaration of ‘SwapAnchor’ must be available [-fpermissive] SwapAnchor(anchor_, other.anchor_); ^~~~~~~~~~ ../../third_party/WebKit/Source/platform/wtf/LinkedHashSet.h:691:3: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated) ninja: build stopped: subcommand failed. To fix it move the SwapAnchor and swap declaration before the templates block (above the first SwapAnchor call). Change-Id: Idd902ef00f0165d157dee886406f6be78191f80b Reviewed-on: https://chromium-review.googlesource.com/616563 Reviewed-by: Yuta Kitamura Commit-Queue: Yuta Kitamura Cr-Commit-Position: refs/heads/master@{#494751} --- diff --git a/third_party/WebKit/Source/platform/wtf/LinkedHashSet.h b/third_party/WebKit/Source/platform/wtf/LinkedHashSet.h index 83826b4..2b78d24 100644 --- a/third_party/WebKit/Source/platform/wtf/LinkedHashSet.h +++ b/third_party/WebKit/Source/platform/wtf/LinkedHashSet.h @@ -647,6 +647,46 @@ friend class LinkedHashSet; }; +inline void SwapAnchor(LinkedHashSetNodeBase& a, LinkedHashSetNodeBase& b) { + DCHECK(a.prev_); + DCHECK(a.next_); + DCHECK(b.prev_); + DCHECK(b.next_); + swap(a.prev_, b.prev_); + swap(a.next_, b.next_); + if (b.next_ == &a) { + DCHECK_EQ(b.prev_, &a); + b.next_ = &b; + b.prev_ = &b; + } else { + b.next_->prev_ = &b; + b.prev_->next_ = &b; + } + if (a.next_ == &b) { + DCHECK_EQ(a.prev_, &b); + a.next_ = &a; + a.prev_ = &a; + } else { + a.next_->prev_ = &a; + a.prev_->next_ = &a; + } +} + +inline void swap(LinkedHashSetNodeBase& a, LinkedHashSetNodeBase& b) { + DCHECK_NE(a.next_, &a); + DCHECK_NE(b.next_, &b); + swap(a.prev_, b.prev_); + swap(a.next_, b.next_); + if (b.next_) { + b.next_->prev_ = &b; + b.prev_->next_ = &b; + } + if (a.next_) { + a.next_->prev_ = &a; + a.prev_->next_ = &a; + } +} + template inline LinkedHashSet::LinkedHashSet() { static_assert( @@ -877,46 +917,6 @@ erase(find(value)); } -inline void SwapAnchor(LinkedHashSetNodeBase& a, LinkedHashSetNodeBase& b) { - DCHECK(a.prev_); - DCHECK(a.next_); - DCHECK(b.prev_); - DCHECK(b.next_); - swap(a.prev_, b.prev_); - swap(a.next_, b.next_); - if (b.next_ == &a) { - DCHECK_EQ(b.prev_, &a); - b.next_ = &b; - b.prev_ = &b; - } else { - b.next_->prev_ = &b; - b.prev_->next_ = &b; - } - if (a.next_ == &b) { - DCHECK_EQ(a.prev_, &b); - a.next_ = &a; - a.prev_ = &a; - } else { - a.next_->prev_ = &a; - a.prev_->next_ = &a; - } -} - -inline void swap(LinkedHashSetNodeBase& a, LinkedHashSetNodeBase& b) { - DCHECK_NE(a.next_, &a); - DCHECK_NE(b.next_, &b); - swap(a.prev_, b.prev_); - swap(a.next_, b.next_); - if (b.next_) { - b.next_->prev_ = &b; - b.prev_->next_ = &b; - } - if (a.next_) { - a.next_->prev_ = &a; - a.prev_->next_ = &a; - } -} - template inline void swap(LinkedHashSetNode& a, LinkedHashSetNode& b) {