New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 731577 link

Starred by 0 users

Issue metadata

Status: WontFix
Owner:
hobby only
Closed: Jan 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Task



Sign in to add a comment

Turn the move_raw clang tool into a clang-tidy check

Project Member Reported by vabr@chromium.org, Jun 9 2017

Issue description

After https://codereview.chromium.org/2919243002/, there will be a move_raw clang tool in Chromium, to find instances where std::move() is called on a raw pointer (which are likely a programming error).

This check could be made a part of the static analysis done by clang-tidy instead.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Jun 9 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/9ed3f43a6cc49b844d769498283b2e1e0be6cb94

commit 9ed3f43a6cc49b844d769498283b2e1e0be6cb94
Author: vabr <vabr@chromium.org>
Date: Fri Jun 09 07:30:42 2017

Add a clang tool to detect std::move(raw ptr)

The CL also adds a sentence to the documentation for clang tools, to supply a
bit which was unclear for me during writing of the added tool.

So far, on Linux, the tool found instances of std::move(raw ptr) in:

../../components/browser_sync/profile_sync_service.cc:10101
../../components/sync_sessions/sessions_sync_manager.cc:5987
../../content/browser/indexed_db/indexed_db_transaction.cc:3865
../../gpu/ipc/service/gpu_channel.cc:26467
../../services/preferences/tracked/pref_hash_store_impl.cc:3329
../../services/preferences/tracked/pref_hash_store_impl.cc:4518
../../services/ui/public/cpp/bitmap/child_shared_bitmap_manager.cc:5009
../../services/video_capture/test/mock_device_factory.cc:2266

It also found it in some 3rd party headers, such as
../../third_party/flatbuffers/src/include/flatbuffers/flatbuffers.h:8260
../../third_party/skia/include/core/SkCanvas.h:14756
../../third_party/webrtc/api/proxy.h:16937
../../third_party/webrtc/api/proxy.h:19681
../../third_party/webrtc/api/proxy.h:20241
and c++ libs.

The Chromium 1st party instances will be addressed in separate CLs. For the headers, I'll consider if it makes sense to address this (e.g., some occurrences seem to be template instantiations, where the template is not a priori aware that the supplied type is a raw pointer; in such cases std::move should stay).

I may also run the tool on more platforms.

Finally, while preventing regressions would be good, it seems impractical to run this tool as a presubmit check. However, I will try to run it after https://crbug.com/646113 is finished, because that base::Value refactoring might introduce some instances (happened to me recently).

BUG= 729393 , 731577 

Review-Url: https://codereview.chromium.org/2919243002
Cr-Commit-Position: refs/heads/master@{#478226}

[modify] https://crrev.com/9ed3f43a6cc49b844d769498283b2e1e0be6cb94/docs/clang_tool_refactoring.md
[add] https://crrev.com/9ed3f43a6cc49b844d769498283b2e1e0be6cb94/tools/clang/move_raw/CMakeLists.txt
[add] https://crrev.com/9ed3f43a6cc49b844d769498283b2e1e0be6cb94/tools/clang/move_raw/MoveRaw.cpp
[add] https://crrev.com/9ed3f43a6cc49b844d769498283b2e1e0be6cb94/tools/clang/move_raw/tests/test-expected.cc
[add] https://crrev.com/9ed3f43a6cc49b844d769498283b2e1e0be6cb94/tools/clang/move_raw/tests/test-original.cc

Comment 2 by vabr@chromium.org, Jun 12 2017

Status: WontFix (was: Available)
Turns out, dvadym@ already implemented this some time ago: https://clang.llvm.org/extra/clang-tidy/checks/misc-move-const-arg.html

Comment 3 by mar...@chromium.org, Jan 22 2018

Should tools/clang/move_raw/ be removed? I don't see it being referenced.

Comment 5 by vabr@chromium.org, Jan 23 2018

Owner: vabr@chromium.org
Status: Started (was: WontFix)

Comment 7 by vabr@chromium.org, Jan 23 2018

Status: WontFix (was: Started)

Sign in to add a comment