[clang-tidy] Add a module for the Linux kernel.
authorTom Roeder <tmroeder@google.com>
Thu, 25 Jul 2019 22:32:50 +0000 (22:32 +0000)
committerTom Roeder <tmroeder@google.com>
Thu, 25 Jul 2019 22:32:50 +0000 (22:32 +0000)
commitfc8c65b2e11d21b1c0ce070cc0a4ee031a542dae
tree3186d37aa172fc2b78871434b167cf01aabe588e
parent3d21a3af8716658b257830461e33673d49906271
[clang-tidy] Add a module for the Linux kernel.

Summary:
Now that clang is going to be able to build the Linux kernel again on
x86, and we have gen_compile_commands.py upstream for generating
compile_commands.json, clang-tidy can be used on the Linux kernel
source.

To that end, this commit adds a new clang-tidy module to be used for
checks specific to Linux kernel source. The Linux kernel follows its own
style of C, and it will be useful to separate those checks into their
own module.

This also adds an initial check that makes sure that return values from
the kernel error functions like PTR_ERR and ERR_PTR are checked. It also
makes sure that any functions that directly return values from these
functions are checked.

Subscribers: xazax.hun, gribozavr, Eugene.Zelenko, lebedev.ri, mgorny, jdoerfert, cfe-commits

Tags: #clang, #clang-tools-extra

Reviewers: aaron.ballman, alexfh, hokein, JonasToth

Differential Revision: https://reviews.llvm.org/D59963

llvm-svn: 367071
12 files changed:
clang-tools-extra/clang-tidy/CMakeLists.txt
clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
clang-tools-extra/clang-tidy/linuxkernel/CMakeLists.txt [new file with mode: 0644]
clang-tools-extra/clang-tidy/linuxkernel/LinuxKernelTidyModule.cpp [new file with mode: 0644]
clang-tools-extra/clang-tidy/linuxkernel/MustCheckErrsCheck.cpp [new file with mode: 0644]
clang-tools-extra/clang-tidy/linuxkernel/MustCheckErrsCheck.h [new file with mode: 0644]
clang-tools-extra/clang-tidy/plugin/CMakeLists.txt
clang-tools-extra/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/linuxkernel-must-use-errs.rst [new file with mode: 0644]
clang-tools-extra/docs/clang-tidy/checks/list.rst
clang-tools-extra/test/clang-tidy/linuxkernel-must-check-errs.c [new file with mode: 0644]