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

Issue 732867 link

Starred by 1 user

Issue metadata

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



Sign in to add a comment

Ensure that move_raw clang tool is well replaced with clang-tidy

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

Issue description

The check done by tools/clang/move_raw is contained in clang-tidy: https://clang.llvm.org/extra/clang-tidy/checks/misc-move-const-arg.html.

This task tracks:
(1) Checking that clang-tidy is actually comparable easy to use as the clang tool.
(2) Updating the docs https://chromium.googlesource.com/chromium/src/+/lkcr/docs/clang_tidy.md to contain as easy an flow as currently possible.
(3) Deleting move_raw it clang-tidy is reasonably useful, or restarting the discussion from https://codereview.chromium.org/2919243002/ is not.
 

Comment 1 by vabr@chromium.org, Jun 22 2017

One side-issue I'm looking at is how to reuse tools/clang/scripts/update.py to build clang-tidy, instead of having to check out llvm separately. The thing I need to solve is that update.py sets the compiler for Chromium to be the compiled clang, which makes goma very slow for me (local fallbacks?). https://chromium.googlesource.com/chromium/src/+/lkcr/docs/clang_tidy.md seems to say that Chromium can be compiled with the normal clang and still clang-tidy will work.

Comment 2 by vabr@chromium.org, Jul 1 2017

Cc: thakis@chromium.org dcheng@chromium.org
I suspect I'm holding it wrong. dcheng@ or thakis@, if you spot what I'm doing wrong, please let me know:

Following https://chromium.googlesource.com/chromium/src/+/lkcr/docs/clang_tidy.md was actually surprisingly easy, and I ended up with my own clang-tidy compiled and running against my compilation.

However, clang-tidy reports just success and does not report any issues.

I put the following code inside base/values_unittest.cc (chosen randomly):

  int F() {
    return std::move(42);
  }

  TEST(ClangTidy, MiscMoveConstArg) {
    EXPECT_EQ(42, F());
  }

Then I build base_unittests in debug (also in release, none worked):

  ninja -C out/gn-dbg/ base_unittests

Then I generated the compile DB:

  tools/clang/scripts/generate_compdb.py -p out/gn-dbg/ > compile_commands.json

Then I ran clang-tidy:

  cd out/gn-dbg

  export LLVM_DIR=... # The dir with llvm repo under llvm/ and build dir under build/

  $LLVM_DIR/llvm/tools/clang/tools/extra/clang-tidy/tool/run-clang-tidy.py -p ../.. -clang-tidy-binary $LLVM_DIR/build/bin/clang-tidy -clang-apply-replacements-binary $LLVM_DIR/build/bin/clang-apply-replacements -checks='-*,misc-move-const-arg' -fix base/values_unittests.cc

The output was:
-----
Enabled checks:
    misc-move-const-arg


clang-apply-replacements version 5.0.0
Applying fixes ...

-----
And no files were changed.

Comment 3 by vabr@chromium.org, Jul 1 2017

I should also say that the code supposed to break was adapted from https://github.com/llvm-mirror/clang-tools-extra/blob/master/test/clang-tidy/misc-move-const-arg.cpp. So I'm sure I do something wrong, I just don't see what it is.

Comment 4 by vabr@chromium.org, Jul 1 2017

(And 'ninja check-clang-tools' in my llvm/build dir passes.)

Comment 5 by vabr@chromium.org, Oct 20 2017

Note for myself: https://crbug.com/403854#c13 contains step-by-step instructions for running clang-tidy. I should try them once I get to retrying #2 here.

Comment 6 by vabr@chromium.org, Apr 6 2018

Status: WontFix (was: Assigned)
I don't think I will have time to look into clang-tidy any time soon. The move_raw clang tool is long gone (r531197), so this is not blocking anyone. Therefore, let me close this task.

Sign in to add a comment