Turn on -Wrange-loop-analysis.

-Wrange-loop-analysis triggers when we use a new-style for loop in a way that appears to unintentionally call a copy constructor on each non-trivial loop element instead of operating on them by reference.


BUG=skia:

GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4000

Change-Id: If9e1b7fcc1f2789ae03c41c17abb17e60d564a8b
Reviewed-on: https://skia-review.googlesource.com/4000
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
Mike Klein 2016-10-26 10:35:22 -04:00 committed by Skia Commit-Bot
parent f93f515161
commit 6ad9909fb7
3 changed files with 22 additions and 23 deletions

View File

@ -284,7 +284,6 @@ config("warnings") {
]
cflags_cc += [
"-Wno-abstract-vbase-init",
"-Wno-range-loop-analysis",
"-Wno-weak-vtables",
]

View File

@ -249,8 +249,8 @@ void Compiler::scanCFG(CFG* cfg, BlockId blockId, std::set<BlockId>* workList) {
// is initially unknown
static std::unordered_map<const Variable*, const Expression*> compute_start_state(const CFG& cfg) {
std::unordered_map<const Variable*, const Expression*> result;
for (const auto block : cfg.fBlocks) {
for (const auto node : block.fNodes) {
for (const auto& block : cfg.fBlocks) {
for (const auto& node : block.fNodes) {
if (node.fKind == BasicBlock::Node::kStatement_Kind) {
const Statement* s = (Statement*) node.fNode;
if (s->fKind == Statement::kVarDeclarations_Kind) {

View File

@ -690,7 +690,7 @@ static void test_matchStyleCSS3(skiatest::Reporter* reporter) {
};
for (StyleSetTest& test : tests) {
for (const StyleSetTest::Case testCase : test.cases) {
for (const StyleSetTest::Case& testCase : test.cases) {
SkAutoTUnref<SkTypeface> typeface(test.styleSet.matchStyle(testCase.pattern));
if (typeface) {
REPORTER_ASSERT(reporter, typeface->fontStyle() == testCase.expectedResult);