Blob Blame History Raw
From 56cb5f7da1025f6db869e840ed34d3b98b9ab899 Mon Sep 17 00:00:00 2001
From: Jose Dapena Paz <jose.dapena@lge.com>
Date: Tue, 29 May 2018 16:04:14 +0000
Subject: [PATCH] GCC: do not std::move unique ptr of forward declared UrlIndex
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

GCC fails to resolve the size of UrlIndex, needed
for moving a std::unique_ptr of UrlIndex. This is because
moved is done on a forward-declared UrlIndex.

To avoid the problem, move the call to std::move to the .cc
file so the full declaration is available.

Build error:
../../buildtools/third_party/libc++/trunk/include/memory: In instantiation of ‘void std::__1::default_delete<_Tp>::operator()(_Tp*) const [with _Tp = bookmarks::UrlIndex]’:
../../buildtools/third_party/libc++/trunk/include/memory:2634:22:   required from ‘void std::__1::unique_ptr<_Tp, _Dp>::reset(std::__1::unique_ptr<_Tp, _Dp>::pointer) [with _Tp = bookmarks::UrlIndex; _Dp = std::__1::default_delete<bookmarks::UrlIndex>; std::__1::unique_ptr<_Tp, _Dp>::pointer = bookmarks::UrlIndex*]’
../../buildtools/third_party/libc++/trunk/include/memory:2588:24:   required from ‘std::__1::unique_ptr<_Tp, _Dp>::~unique_ptr() [with _Tp = bookmarks::UrlIndex; _Dp = std::__1::default_delete<bookmarks::UrlIndex>]’
../../components/bookmarks/browser/bookmark_storage.h:107:76:   required from here
../../buildtools/third_party/libc++/trunk/include/memory:2317:25: error: invalid application of ‘sizeof’ to incomplete type ‘bookmarks::UrlIndex’
     static_assert(sizeof(_Tp) > 0,

Bug: 819294
Change-Id: I793a807c28e797aaa2e31d9c8b7e09fb6ca6b9e7
Reviewed-on: https://chromium-review.googlesource.com/1071648
Commit-Queue: Scott Violet <sky@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#562446}
---
 components/bookmarks/browser/bookmark_storage.cc | 4 ++++
 components/bookmarks/browser/bookmark_storage.h  | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/components/bookmarks/browser/bookmark_storage.cc b/components/bookmarks/browser/bookmark_storage.cc
index 1633ba1df2a4..3ae0c62292e7 100644
--- a/components/bookmarks/browser/bookmark_storage.cc
+++ b/components/bookmarks/browser/bookmark_storage.cc
@@ -158,6 +158,10 @@ void BookmarkLoadDetails::CreateUrlIndex() {
   url_index_ = std::make_unique<UrlIndex>(std::move(root_node_));
 }
 
+std::unique_ptr<UrlIndex> BookmarkLoadDetails::owned_url_index() {
+  return std::move(url_index_);
+}
+
 BookmarkPermanentNode* BookmarkLoadDetails::CreatePermanentNode(
     BookmarkClient* client,
     BookmarkNode::Type type) {
diff --git a/components/bookmarks/browser/bookmark_storage.h b/components/bookmarks/browser/bookmark_storage.h
index 08df5bb65d83..0a1b1a1b65b9 100644
--- a/components/bookmarks/browser/bookmark_storage.h
+++ b/components/bookmarks/browser/bookmark_storage.h
@@ -104,7 +104,7 @@ class BookmarkLoadDetails {
   bool ids_reassigned() const { return ids_reassigned_; }
 
   void CreateUrlIndex();
-  std::unique_ptr<UrlIndex> owned_url_index() { return std::move(url_index_); }
+  std::unique_ptr<UrlIndex> owned_url_index();
 
  private:
   // Creates one of the possible permanent nodes (bookmark bar node, other node
-- 
2.17.1