Commit 7053a3a2 authored by Jan Wilken Dörrie's avatar Jan Wilken Dörrie Committed by Commit Bot

Revert "flat_map: Readd constructors and assignment operator overloads."

This reverts commit 1131840b.

Reason for revert: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89381
got fixed and this change interferes with https://crrev.com/c/2494941.
That change added a new sorted_unique_t constructor tag to
base::flat_tree, but wasn't taking effect for flat_map, since those
constructors were not inherited.


Original change's description:
> flat_map: Readd constructors and assignment operator overloads.
>
> https://chromium-review.googlesource.com/c/chromium/src/+/705955 ("base::flat_map
> was missing defaults for duplication handling") removed them in favor of
> inheriting them from flat_tree.
>
> This can cause problems with GCC due to
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84782, and the build has been
> failing with it since
> https://chromium-review.googlesource.com/1000393 ("Mojo C++ Bindings:
> unordered_map => flat_map") with a message like this:
>
>     gen/mojo/public/interfaces/bindings/tests/test_unions.mojom.cc: In member function ‘void mojo::test::ObjectUnion::set_f_map_int8(const base::flat_map<std::__cxx11::basic_string<char>, signed char>&)’:
>     gen/mojo/public/interfaces/bindings/tests/test_unions.mojom.cc:455:30: error: use of deleted function ‘base::flat_map<std::__cxx11::basic_string<char>, signed char>::flat_map(const base::flat_map<std::__cxx11::basic_string<char>, signed char>&)’
>              std::move(f_map_int8));
>                                   ^
>     In file included from ../../mojo/public/cpp/bindings/clone_traits.h:11:0,
>                      from gen/mojo/public/interfaces/bindings/tests/test_unions.mojom.h:22,
>                      from gen/mojo/public/interfaces/bindings/tests/test_unions.mojom.cc:15:
>     ../../base/containers/flat_map.h:152:7: note: ‘base::flat_map<std::__cxx11::basic_string<char>, signed char>::flat_map(const base::flat_map<std::__cxx11::basic_string<char>, signed char>&)’ is implicitly declared as deleted because ‘base::flat_map<std::__cxx11::basic_string<char>, signed char>’ declares a move constructor or move assignment operator
>      class flat_map : public ::base::internal::flat_tree<
>            ^~~~~~~~
>
> Work around it by replacing the inheritance statements with actual
> constructors and operator=() overloads again. This change does not
> completely revert https://chromium-review.googlesource.com/1000393, as the
> constructors maintain their new signature (so that they look like
> flat_tree's).
>
> Bug: 819294, 837221
> Change-Id: I8f37a2c8aa269b3c1025cdc009518a7709e95947
> Reviewed-on: https://chromium-review.googlesource.com/1038103
> Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Reviewed-by: kylechar <kylechar@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#556168}

TBR=danakj@chromium.org,dcheng@chromium.org,raphael.kubo.da.costa@intel.com,kylechar@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 819294
Bug: 837221
Change-Id: I72915a49981c114f16eaa866de226e9cd242a348
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2526100Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825738}
parent 2877dea5
...@@ -205,34 +205,14 @@ class flat_map : public ::base::internal::flat_tree< ...@@ -205,34 +205,14 @@ class flat_map : public ::base::internal::flat_tree<
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// Lifetime and assignments. // Lifetime and assignments.
// //
// Note: we could do away with these constructors, destructor and assignment // Note: we explicitly bring operator= in because otherwise
// operator overloads by inheriting |tree|'s, but this breaks the GCC build // flat_map<...> x;
// due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84782 (see // x = {...};
// https://crbug.com/837221). // Would first create a flat_map and then move assign it. This most likely
// would be optimized away but still affects our debug builds.
flat_map() = default;
explicit flat_map(const Compare& comp);
template <class InputIterator>
flat_map(InputIterator first,
InputIterator last,
const Compare& comp = Compare());
flat_map(const flat_map&) = default;
flat_map(flat_map&&) noexcept = default;
flat_map(const container_type& items, const Compare& comp = Compare());
flat_map(container_type&& items, const Compare& comp = Compare());
flat_map(std::initializer_list<value_type> ilist,
const Compare& comp = Compare());
~flat_map() = default;
flat_map& operator=(const flat_map&) = default; using tree::tree;
flat_map& operator=(flat_map&&) noexcept = default; using tree::operator=;
// Takes the first if there are duplicates in the initializer list.
flat_map& operator=(std::initializer_list<value_type> ilist);
// Out-of-bound calls to at() will CHECK. // Out-of-bound calls to at() will CHECK.
template <class K> template <class K>
...@@ -275,52 +255,6 @@ class flat_map : public ::base::internal::flat_tree< ...@@ -275,52 +255,6 @@ class flat_map : public ::base::internal::flat_tree<
friend void swap(flat_map& lhs, flat_map& rhs) noexcept { lhs.swap(rhs); } friend void swap(flat_map& lhs, flat_map& rhs) noexcept { lhs.swap(rhs); }
}; };
// ----------------------------------------------------------------------------
// Lifetime.
template <class Key, class Mapped, class Compare, class Container>
flat_map<Key, Mapped, Compare, Container>::flat_map(const Compare& comp)
: tree(comp) {}
template <class Key, class Mapped, class Compare, class Container>
template <class InputIterator>
flat_map<Key, Mapped, Compare, Container>::flat_map(InputIterator first,
InputIterator last,
const Compare& comp)
: tree(first, last, comp) {}
template <class Key, class Mapped, class Compare, class Container>
flat_map<Key, Mapped, Compare, Container>::flat_map(const container_type& items,
const Compare& comp)
: tree(items, comp) {}
template <class Key, class Mapped, class Compare, class Container>
flat_map<Key, Mapped, Compare, Container>::flat_map(container_type&& items,
const Compare& comp)
: tree(std::move(items), comp) {}
template <class Key, class Mapped, class Compare, class Container>
flat_map<Key, Mapped, Compare, Container>::flat_map(
std::initializer_list<value_type> ilist,
const Compare& comp)
: flat_map(std::begin(ilist), std::end(ilist), comp) {}
// ----------------------------------------------------------------------------
// Assignments.
template <class Key, class Mapped, class Compare, class Container>
auto flat_map<Key, Mapped, Compare, Container>::operator=(
std::initializer_list<value_type> ilist) -> flat_map& {
// When https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84782 gets fixed, we
// need to remember to inherit tree::operator= to prevent
// flat_map<...> x;
// x = {...};
// from first creating a flat_map and then move assigning it. This most
// likely would be optimized away but still affects our debug builds.
tree::operator=(ilist);
return *this;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Lookups. // Lookups.
......
...@@ -97,7 +97,8 @@ IppRequestPtr GetBasicIppRequest() { ...@@ -97,7 +97,8 @@ IppRequestPtr GetBasicIppRequest() {
ret->http_version = "HTTP/1.1"; ret->http_version = "HTTP/1.1";
// Map of Http headers. // Map of Http headers.
ret->headers = std::vector<ipp_converter::HttpHeader>{ ret->headers = base::flat_map<ipp_converter::HttpHeader::first_type,
ipp_converter::HttpHeader::second_type>{
{"Content-Length", "72"}, {"Content-Length", "72"},
{"Content-Type", "application/ipp"}, {"Content-Type", "application/ipp"},
{"Date", "Thu, 04 Oct 2018 20:25:59 GMT"}, {"Date", "Thu, 04 Oct 2018 20:25:59 GMT"},
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "base/containers/flat_map.h"
#include "base/optional.h" #include "base/optional.h"
#include "chrome/services/cups_proxy/public/cpp/type_conversions.h" #include "chrome/services/cups_proxy/public/cpp/type_conversions.h"
#include "chrome/services/ipp_parser/public/cpp/ipp_converter.h" #include "chrome/services/ipp_parser/public/cpp/ipp_converter.h"
...@@ -181,7 +182,8 @@ void IppParser::ParseIpp(const std::vector<uint8_t>& to_parse, ...@@ -181,7 +182,8 @@ void IppParser::ParseIpp(const std::vector<uint8_t>& to_parse,
parsed_request->endpoint = request_line_terms[1]; parsed_request->endpoint = request_line_terms[1];
parsed_request->http_version = request_line_terms[2]; parsed_request->http_version = request_line_terms[2];
parsed_request->headers = std::move(*headers); parsed_request->headers =
base::flat_map<std::string, std::string>(std::move(*headers));
parsed_request->ipp = std::move(ipp_message); parsed_request->ipp = std::move(ipp_message);
parsed_request->data = std::move(ipp_data); parsed_request->data = std::move(ipp_data);
......
...@@ -48,8 +48,8 @@ blink::mojom::FetchAPIRequestPtr DeserializeFetchRequestFromString( ...@@ -48,8 +48,8 @@ blink::mojom::FetchAPIRequestPtr DeserializeFetchRequestFromString(
request_ptr->frame_type = blink::mojom::RequestContextFrameType::kNone; request_ptr->frame_type = blink::mojom::RequestContextFrameType::kNone;
request_ptr->url = GURL(request_proto.url()); request_ptr->url = GURL(request_proto.url());
request_ptr->method = request_proto.method(); request_ptr->method = request_proto.method();
request_ptr->headers = {request_proto.headers().begin(), request_ptr->headers = blink::FetchAPIRequestHeadersMap(
request_proto.headers().end()}; request_proto.headers().begin(), request_proto.headers().end());
request_ptr->referrer = blink::mojom::Referrer::New( request_ptr->referrer = blink::mojom::Referrer::New(
GURL(request_proto.referrer().url()), GURL(request_proto.referrer().url()),
......
...@@ -117,7 +117,7 @@ blink::mojom::FetchAPIRequestPtr CreateFetchAPIRequest( ...@@ -117,7 +117,7 @@ blink::mojom::FetchAPIRequestPtr CreateFetchAPIRequest(
auto request = blink::mojom::FetchAPIRequest::New(); auto request = blink::mojom::FetchAPIRequest::New();
request->url = url; request->url = url;
request->method = method; request->method = method;
request->headers = {headers.begin(), headers.end()}; request->headers = headers;
request->referrer = std::move(referrer); request->referrer = std::move(referrer);
request->is_reload = is_reload; request->is_reload = is_reload;
return request; return request;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment