[Webkit-unassigned] [Bug 171632] [Tools] Add support for clang-tidy

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed May 3 18:22:28 PDT 2017


https://bugs.webkit.org/show_bug.cgi?id=171632

--- Comment #1 from Don Olmstead <don.olmstead at am.sony.com> ---
To install clang-tidy you can use one of the releases, http://releases.llvm.org/download.html, or on Linux use one of the nightly packages through, http://apt.llvm.org/.

To run clang-tidy you need to be doing a CMake build using a Ninja generator and of course be using clang.

CMake can support clang-tidy through a CMake define, -DCMAKE_EXPORT_COMPILE_COMMANDS=ON. This will generate a compile_commands.json which is used by clang-tidy.

As an example the following command for JSCOnly on Linux will generate the compile_commands.json.

./Tools/Scripts/build-webkit --jsconly --cmakeargs="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"

After CMake is done you can just kill the command since the compile_commands.json will be generated by the time the build starts.

If there is a specific file you would like to analyze use the following command with clang-tidy 0.5 installed through a nightly package.

clang-tidy -checks='-*,modernize*' -header-filter='.*' -fix -format-style=webkit -p WebKitBuild/Release/ Source/WTF/wtf/CPUTime.cpp 

If you would like to analyze everything the following can be used. Since it runs on all files in the project you can output to a file. In this command headers are not scanned.

run-clang-tidy-5.0.py -p WebKitBuild/Release > clang-tidy-run-0.5.txt 2>&1

If you would like to apply modernize fixes you can run the following as an example.

clang-tidy -checks='-*,modernize*' -header-filter='.*' -fix -format-style=webkit -p WebKitBuild/Release/ Source/WTF/wtf/CPUTime.cpp

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20170504/fcecdeff/attachment.html>


More information about the webkit-unassigned mailing list