Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

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

Created:
3 years, 6 months ago by vabr (Chromium)
Modified:
3 years, 6 months ago
Reviewers:
Nico, dcheng
CC:
chromium-reviews, jdoerrie
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

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} Committed: https://chromium.googlesource.com/chromium/src/+/9ed3f43a6cc49b844d769498283b2e1e0be6cb94

Patch Set 1 #

Total comments: 14

Patch Set 2 : Just rebased #

Patch Set 3 : Avoid Replacements; only log when there is at least 1 Replacement #

Patch Set 4 : vector -> set #

Patch Set 5 : Add a TODO to make this a clang-tidy check #

Unified diffs Side-by-side diffs Delta from patch set Stats (+211 lines, -0 lines) Patch
M docs/clang_tool_refactoring.md View 1 chunk +6 lines, -0 lines 0 comments Download
A tools/clang/move_raw/CMakeLists.txt View 1 chunk +28 lines, -0 lines 0 comments Download
A tools/clang/move_raw/MoveRaw.cpp View 1 2 3 4 1 chunk +97 lines, -0 lines 0 comments Download
A tools/clang/move_raw/tests/test-expected.cc View 1 chunk +40 lines, -0 lines 0 comments Download
A tools/clang/move_raw/tests/test-original.cc View 1 chunk +40 lines, -0 lines 0 comments Download

Messages

Total messages: 31 (11 generated)
vabr (Chromium)
Hi dcheng@, Could you please review? Hi jdoerrie@, No need for you to review, just ...
3 years, 6 months ago (2017-06-04 10:56:17 UTC) #3
vabr (Chromium)
https://codereview.chromium.org/2919243002/diff/1/tools/clang/move_raw/MoveRaw.cpp File tools/clang/move_raw/MoveRaw.cpp (right): https://codereview.chromium.org/2919243002/diff/1/tools/clang/move_raw/MoveRaw.cpp#newcode44 tools/clang/move_raw/MoveRaw.cpp:44: auto err = replacements_->add(clang::tooling::Replacement( It turned out that this ...
3 years, 6 months ago (2017-06-04 13:22:24 UTC) #8
dcheng
https://codereview.chromium.org/2919243002/diff/1/tools/clang/move_raw/MoveRaw.cpp File tools/clang/move_raw/MoveRaw.cpp (right): https://codereview.chromium.org/2919243002/diff/1/tools/clang/move_raw/MoveRaw.cpp#newcode44 tools/clang/move_raw/MoveRaw.cpp:44: auto err = replacements_->add(clang::tooling::Replacement( On 2017/06/04 13:22:24, vabr (Chromium) ...
3 years, 6 months ago (2017-06-07 19:58:34 UTC) #9
vabr (Chromium)
Thanks for the review! Please take another look. Cheers, Vaclav https://codereview.chromium.org/2919243002/diff/1/tools/clang/move_raw/MoveRaw.cpp File tools/clang/move_raw/MoveRaw.cpp (right): https://codereview.chromium.org/2919243002/diff/1/tools/clang/move_raw/MoveRaw.cpp#newcode44 ...
3 years, 6 months ago (2017-06-08 12:37:49 UTC) #10
dcheng
https://codereview.chromium.org/2919243002/diff/1/tools/clang/move_raw/MoveRaw.cpp File tools/clang/move_raw/MoveRaw.cpp (right): https://codereview.chromium.org/2919243002/diff/1/tools/clang/move_raw/MoveRaw.cpp#newcode44 tools/clang/move_raw/MoveRaw.cpp:44: auto err = replacements_->add(clang::tooling::Replacement( On 2017/06/08 12:37:49, vabr (Chromium) ...
3 years, 6 months ago (2017-06-08 19:40:43 UTC) #11
vabr (Chromium)
Hi dcheng! I changed vector to set, but perhaps we have a little misunderstanding about ...
3 years, 6 months ago (2017-06-09 07:02:58 UTC) #12
dcheng
We probably want to eventually turn this into a clang-tidy check, maybe add a TODO ...
3 years, 6 months ago (2017-06-09 07:06:41 UTC) #13
dcheng
https://codereview.chromium.org/2919243002/diff/1/tools/clang/move_raw/MoveRaw.cpp File tools/clang/move_raw/MoveRaw.cpp (right): https://codereview.chromium.org/2919243002/diff/1/tools/clang/move_raw/MoveRaw.cpp#newcode44 tools/clang/move_raw/MoveRaw.cpp:44: auto err = replacements_->add(clang::tooling::Replacement( On 2017/06/09 07:02:57, vabr (Chromium) ...
3 years, 6 months ago (2017-06-09 07:08:33 UTC) #14
vabr (Chromium)
Thank you for the quick response! I added the TODO and https://crbug.com/731577 to track the ...
3 years, 6 months ago (2017-06-09 07:19:38 UTC) #16
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2919243002/80001
3 years, 6 months ago (2017-06-09 07:20:00 UTC) #19
commit-bot: I haz the power
Committed patchset #5 (id:80001) as https://chromium.googlesource.com/chromium/src/+/9ed3f43a6cc49b844d769498283b2e1e0be6cb94
3 years, 6 months ago (2017-06-09 07:30:59 UTC) #22
Nico
On 2017/06/09 07:30:59, commit-bot: I haz the power wrote: > Committed patchset #5 (id:80001) as ...
3 years, 6 months ago (2017-06-12 10:48:29 UTC) #23
vabr (Chromium)
On 2017/06/12 10:48:29, Nico (vacation Jun 3-11) wrote: > Wouldn't this make more sense as ...
3 years, 6 months ago (2017-06-12 10:58:04 UTC) #24
vabr (Chromium)
So today I found out that a colleague (dvadym@) implemented this as a clang-tidy check ...
3 years, 6 months ago (2017-06-12 13:07:49 UTC) #25
Nico
On Mon, Jun 12, 2017 at 6:48 AM, <thakis@chromium.org> wrote: > On 2017/06/09 07:30:59, commit-bot: ...
3 years, 6 months ago (2017-06-13 14:05:27 UTC) #26
Nico
Sorry, hadn't seen your reply. I think this probably passes the bar for a compiler ...
3 years, 6 months ago (2017-06-13 16:11:45 UTC) #27
vabr (Chromium)
Thanks, Nico, for the answer. As for clang-tidy, as long as using it is not ...
3 years, 6 months ago (2017-06-13 17:25:53 UTC) #28
dcheng
On 2017/06/13 17:25:53, vabr (Chromium) wrote: > Thanks, Nico, for the answer. > > As ...
3 years, 6 months ago (2017-06-13 17:30:11 UTC) #29
vabr (Chromium)
On 2017/06/13 17:30:11, dcheng wrote: > On 2017/06/13 17:25:53, vabr (Chromium) wrote: > > Thanks, ...
3 years, 6 months ago (2017-06-13 17:40:08 UTC) #30
Nico
3 years, 6 months ago (2017-06-13 17:42:01 UTC) #31
Message was sent while issue was closed.
On Tue, Jun 13, 2017 at 1:40 PM, <vabr@chromium.org> wrote:

> On 2017/06/13 17:30:11, dcheng wrote:
> > On 2017/06/13 17:25:53, vabr (Chromium) wrote:
> > > Thanks, Nico, for the answer.
> > >
> > > As for clang-tidy, as long as using it is not substantially harder than
> > running
> > > the tool, I'm all for removing this tool. Reading
> > > https://chromium.googlesource.com/chromium/src/+/lkcr/docs/
> clang_tidy.md, it
> > is
> > > reported "experimental" and "somewhat painful to use". Is this
> comparable to
> > > clang tools? In particular, I loved how clang tools got the llvm+clang
> repos
> > and
> > > bootstrapped clang with one comment. That should presumably also work
> for
> > > clang-tidy?
> > >
> > > As for the warning, that sounds also good, although there the TODO is
> to
> avoid
> > > templated code (currently source of false-positives in this tool). I
> sadly
> > never
> > > contributed to clang before, but I have Google's clang team in a
> walking
> > > distance, so hopefully this could work. I'm not sure when I could get
> to it,
> > but
> > > it does not sound urgent.
> > >
> > > Cheers,
> > > Vaclav
> >
> > It was painful the last time I tried it, but I filed a few bugs and
> there were
> > some fixes. So it's possible the situation is better now. It's worth a
> shot
> > anyway.
>
> OK, so my plan for clang-tidy would be to try it out, and update the above
> linked doc in case improvements (like the automated checking of
> llvm+clang) are
> ready. If clang-tidy does a reasonable job for checking the std::move(raw)
> case,
> I will submit a CL deleting the tool. If not, I will bring up the issues
> with
> both of you to check what would be the best next steps.
>
> Unless you feel this is urgent, it might take me possibly a low number of
> weeks.
> Track the progress at https://crbug.com/732867.
>

Thanks, that sounds like a good plan.

-- 
You received this message because you are subscribed to the Google Groups
"Chromium-reviews" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to chromium-reviews+unsubscribe@chromium.org.

Powered by Google App Engine
This is Rietveld 408576698