Commit caa3fbd1 authored by Bartek Nowierski's avatar Bartek Nowierski Committed by Commit Bot

Use auto& instead of auto in the range loop

There are a couple reasons for this change:
1. Avoid copying 2-pointer struct.
2. If any of the pointers in the struct gets replaced by CheckedPtr with
   a non-trivial constructor, the compiler will complain.

See go/miracleptr for more details on the experimental CheckedPtr project.

Bug: 1080832
Change-Id: Ic2c6c1cc37601a8a22cb0bb2177547ea614fbcea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2434021
Auto-Submit: Bartek Nowierski <bartekn@chromium.org>
Reviewed-by: default avatarMike Wittman <wittman@chromium.org>
Commit-Queue: Bartek Nowierski <bartekn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811476}
parent d1da1bce
...@@ -372,7 +372,7 @@ void ExpectStackDoesNotContain( ...@@ -372,7 +372,7 @@ void ExpectStackDoesNotContain(
std::set<FunctionAddressRange, FunctionAddressRangeCompare> seen_functions; std::set<FunctionAddressRange, FunctionAddressRangeCompare> seen_functions;
for (const auto& frame : stack) { for (const auto& frame : stack) {
for (const auto function : functions) { for (const auto& function : functions) {
if (frame.instruction_pointer >= if (frame.instruction_pointer >=
reinterpret_cast<uintptr_t>(function.start) && reinterpret_cast<uintptr_t>(function.start) &&
frame.instruction_pointer <= frame.instruction_pointer <=
...@@ -382,7 +382,7 @@ void ExpectStackDoesNotContain( ...@@ -382,7 +382,7 @@ void ExpectStackDoesNotContain(
} }
} }
for (const auto function : seen_functions) { for (const auto& function : seen_functions) {
ADD_FAILURE() << "Function at " << function.start ADD_FAILURE() << "Function at " << function.start
<< " was unexpectedly found in stack:\n" << " was unexpectedly found in stack:\n"
<< FormatSampleForDiagnosticOutput(stack); << FormatSampleForDiagnosticOutput(stack);
......
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