chrome plugin: auto fixit generates invalid code |
|||
Issue description
Here's the diff of the fixit output:
$ git diff origin/master -- third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc
diff --git a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc
index 31d3816ac814..88623cb7e637 100644
--- a/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc
+++ b/third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc
@@ -617,7 +617,7 @@ LazyNow TaskQueueManager::CreateLazyNow() const {
size_t TaskQueueManager::GetNumberOfPendingTasks() const {
size_t task_count = 0;
- for (auto& queue : active_queues_)
+ for (auto*& queue : active_queues_)
task_count += queue->GetNumberOfPendingTasks();
return task_count;
}
@@ -631,7 +631,7 @@ TaskQueueManager::AsValueWithSelectorResult(
new base::trace_event::TracedValue());
base::TimeTicks now = real_time_domain()->CreateLazyNow().Now();
state->BeginArray("active_queues");
- for (auto& queue : active_queues_)
+ for (auto*& queue : active_queues_)
queue->AsValueInto(now, state.get());
state->EndArray();
state->BeginArray("queues_to_delete");
@@ -703,7 +703,7 @@ void SweepCanceledDelayedTasksInQueue(
void TaskQueueManager::SweepCanceledDelayedTasks() {
std::map<TimeDomain*, base::TimeTicks> time_domain_now;
- for (const auto& queue : active_queues_)
+ for (auto* const queue : active_queues_)
SweepCanceledDelayedTasksInQueue(queue, &time_domain_now);
}
Here's the build error:
gen/third_party/WebKit/Source/platform/scheduler/base/../../../../../../../../../third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc:620:15: error: variable 'queue' with type 'auto *&' has incompatible initializer of type 'const std::__1::__tree_const_iterator<blink::scheduler::internal::TaskQueueImpl *, std::__1::__tree_node<blink::scheduler::internal::TaskQueueImpl *, void *> *, long>::value_type' (aka 'blink::scheduler::internal::TaskQueueImpl *const')
for (auto*& queue : active_queues_)
^ ~ ../../buildtools/third_party/libc++/trunk/include/set:550:20: note: selected 'begin' function with iterator type 'std::__1::set<blink::scheduler::internal::TaskQueueImpl *, std::__1::less<blink::scheduler::internal::TaskQueueImpl *>, std::__1::allocator<blink::scheduler::internal::TaskQueueImpl *> >::const_iterator' (aka '__tree_const_iterator<blink::scheduler::internal::TaskQueueImpl *, std::__1::__tree_node<blink::scheduler::internal::TaskQueueImpl *, void *> *, long>') const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
^ In file included from gen/third_party/WebKit/Source/platform/scheduler/base/scheduler_jumbo_1.cc:13: gen/third_party/WebKit/Source/platform/scheduler/base/../../../../../../../../../third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.cc:634:15: error: variable 'queue' with type 'auto *&' has incompatible initializer of type 'const std::__1::__tree_const_iterator<blink::scheduler::internal::TaskQueueImpl *, std::__1::__tree_node<blink::scheduler::internal::TaskQueueImpl *, void *> *, long>::value_type' (aka 'blink::scheduler::internal::TaskQueueImpl *const')
for (auto*& queue : active_queues_)
^ ~ ../../buildtools/third_party/libc++/trunk/include/set:550:20: note: selected 'begin' function with iterator type 'std::__1::set<blink::scheduler::internal::TaskQueueImpl *, std::__1::less<blink::scheduler::internal::TaskQueueImpl *>, std::__1::allocator<blink::scheduler::internal::TaskQueueImpl *> >::const_iterator' (aka '__tree_const_iterator<blink::scheduler::internal::TaskQueueImpl *, std::__1::__tree_node<blink::scheduler::internal::TaskQueueImpl *, void *> *, long>')
const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
^
This was with a jumbo build. There's a few quirks of jumbo build that seem to cause it to emit incorrect replacements, so it's possible this could be another example of that.
,
Oct 23 2017
This particular one seems to repro outside the jumbo build though.
,
Oct 23 2017
Seems like the fixit code isn't emitting a const when running on a member within a const function.
,
Oct 24 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/cef8f57d4469e685e07f215d8c298d6a66d34129 commit cef8f57d4469e685e07f215d8c298d6a66d34129 Author: Vladimir Levin <vmpstr@chromium.org> Date: Tue Oct 24 01:52:35 2017 clang-plugin: Check non-local const qualifications for auto fixits. This patch ensures that we check whether the underlying type is const before issuing a fixit. This ensures that things that are typedef'ed like const_iterator issue a correct fixit. R=dcheng@chromium.org Bug: 777595 Change-Id: Id0f2b97ebaa80b9893890d5ff99407c616dafb30 Reviewed-on: https://chromium-review.googlesource.com/734484 Reviewed-by: Daniel Cheng <dcheng@chromium.org> Commit-Queue: Daniel Cheng <dcheng@chromium.org> Cr-Commit-Position: refs/heads/master@{#511001} [modify] https://crrev.com/cef8f57d4469e685e07f215d8c298d6a66d34129/tools/clang/plugins/FindBadConstructsConsumer.cpp [modify] https://crrev.com/cef8f57d4469e685e07f215d8c298d6a66d34129/tools/clang/plugins/tests/auto_raw_pointer.cpp [modify] https://crrev.com/cef8f57d4469e685e07f215d8c298d6a66d34129/tools/clang/plugins/tests/auto_raw_pointer.txt
,
Oct 24 2017
|
|||
►
Sign in to add a comment |
|||
Comment 1 by dcheng@chromium.org
, Oct 23 2017