Skip to content

build: enable -Wrange-loop-analysis #13154

@rebello95

Description

@rebello95

Title: build: enable -Wrange-loop-analysis

Context:

In #13139 we noticed that building with Xcode 12 enables -Wrange-loop-analysis and yields errors preventing Envoy from building. More specifically, this affected Envoy Mobile when building for iOS. The code errors in Envoy code consumed by Envoy Mobile were fixed in #13140, but there are some third parties (not depended on by Envoy Mobile) that prevent us from enabling this build rule in Envoy.

For example:

bazel-out/darwin-fastbuild/bin/external/com_googlesource_quiche/quiche/spdy/core/hpack/hpack_header_table.cc:258:19: error: loop variable 'it' of type 'const std::__1::pair<const std::__1::basic_string_view<char, std::__1::char_traits<char> >, const spdy::HpackEntry *>' creates a copy from type 'const std::__1::pair<const std::__1::basic_string_view<char, std::__1::char_traits<char> >, const spdy::HpackEntry *>' [-Werror,-Wrange-loop-analysis]
  for (const auto it : static_name_index_) {
                  ^
bazel-out/darwin-fastbuild/bin/external/com_googlesource_quiche/quiche/spdy/core/hpack/hpack_header_table.cc:258:8: note: use reference type 'const std::__1::pair<const std::__1::basic_string_view<char, std::__1::char_traits<char> >, const spdy::HpackEntry *> &' to prevent copying
  for (const auto it : static_name_index_) {
       ^~~~~~~~~~~~~~~
bazel-out/darwin-fastbuild/bin/external/com_googlesource_quiche/quiche/spdy/core/hpack/hpack_header_table.cc:266:19: error: loop variable 'it' of type 'const std::__1::pair<const std::__1::basic_string_view<char, std::__1::char_traits<char> >, const spdy::HpackEntry *>' creates a copy from type 'const std::__1::pair<const std::__1::basic_string_view<char, std::__1::char_traits<char> >, const spdy::HpackEntry *>' [-Werror,-Wrange-loop-analysis]
  for (const auto it : dynamic_name_index_) {
                  ^
bazel-out/darwin-fastbuild/bin/external/com_googlesource_quiche/quiche/spdy/core/hpack/hpack_header_table.cc:266:8: note: use reference type 'const std::__1::pair<const std::__1::basic_string_view<char, std::__1::char_traits<char> >, const spdy::HpackEntry *> &' to prevent copying
  for (const auto it : dynamic_name_index_) {
       ^~~~~~~~~~~~~~~
2 errors generated.

Ask:

Enable the -Wrange-loop-analysis rule in Envoy for building once we're able to (after third parties are fixed) to avoid future build failures caused by this error in Envoy Mobile.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions