Page MenuHomePhabricator

[Sema] Remove a -Wrange warning from -Wall
ClosedPublic

Authored by Mordante on Jan 26 2020, 10:16 AM.

Details

Summary

During the review of D73007 Aaron Puchert mentioned warn_for_range_variable_always_copy shouldn't be part of -Wall since some coding styles require for(const auto &bar : bars). This warning would cause false positives for these users. Based on Aaron's proposal refactored the warnings:

  • -Wrange-loop-construct warns about possibly unintended constructor calls. This is part of -Wall. It contains
    • warn_for_range_copy: loop variable A of type B creates a copy from type C
    • warn_for_range_const_reference_copy: loop variable A is initialized with a value of a different type resulting in a copy
  • -Wrange-loop-bind-reference warns about misleading use of reference types. This is not part of -Wall. It contains
    • warn_for_range_variable_always_copy: loop variable A is always a copy because the range of type B does not return a reference

Note the patch is intended to be backported to clang 11, thus the release notes aren't updated.

Diff Detail

Event Timeline

Unit tests: pass. 62197 tests passed, 0 failed and 815 were skipped.

clang-tidy: pass.

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

Looks right to me, but someone else should approve.

This revision is now accepted and ready to land.Jan 27 2020, 1:47 PM
This revision was automatically updated to reflect the committed changes.

Created D73834 to cherry-pick the changes to the release branch and updates the release notes.