Skip to content

Commit e29c61e

Browse files
authored
Merge pull request #17560 from gottesmm/pr-9d67c5b273eaafb2b9bb9f0568014de4ab1296af
[docs] Add a small section about running the static analyzer via clan…
2 parents c55809f + 35c99da commit e29c61e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/DebuggingTheCompiler.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,25 @@ reducing SIL test cases by:
437437
For more information and a high level example, see:
438438
./swift/utils/bug_reducer/README.md.
439439

440+
Using ``clang-tidy`` to run the Static Analyzer
441+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
442+
443+
Recent versions of LLVM package the tool ``clang-tidy``. This can be used in
444+
combination with a json compilation database to run static analyzer checks as
445+
well as cleanups/modernizations on a code-base. Swift's cmake invocation by
446+
default creates one of these json databases at the root path of the swift host
447+
build, for example on macOS::
448+
449+
$PATH_TO_BUILD/swift-macosx-x86_64/compile_commands.json
450+
451+
Using this file, one invokes ``clang-tidy`` on a specific file in the codebase
452+
as follows::
453+
454+
clang-tidy -p=$PATH_TO_BUILD/swift-macosx-x86_64/compile_commands.json $FULL_PATH_TO_FILE
455+
456+
One can also use shell regex to visit multiple files in the same directory. Example::
457+
458+
clang-tidy -p=$PATH_TO_BUILD/swift-macosx-x86_64/compile_commands.json $FULL_PATH_TO_DIR/*.cpp
440459

441460
Debugging Swift Executables
442461
===========================

0 commit comments

Comments
 (0)