This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add LLVM_LIBC_CLANG_TIDY option and allow LLVM_LIBC_ENABLE_LINTING without full build.
ClosedPublic

Authored by lntue on Feb 7 2022, 12:29 PM.

Details

Summary

Add LLVM_LIBC_CLANG_TIDY option and allow LLVM_LIBC_ENABLE_LINTING without full build.

Diff Detail

Event Timeline

lntue created this revision.Feb 7 2022, 12:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2022, 12:29 PM
lntue requested review of this revision.Feb 7 2022, 12:29 PM
sivachandra added inline comments.Feb 7 2022, 11:47 PM
libc/CMakeLists.txt
56

Check whether that clang-tidy has the checks LLVM libc needs. This could be as simple as checking its version that it is good enough, and then matching it with the version of clang.

65

Same thing here?

68

We should probably not have this fallback at all? For, there is no guarantee that the compilers are in sync with the HEAD clang-tidy?

libc/cmake/modules/LLVMLibCObjectRules.cmake
280–281

Why is this required?

lntue updated this revision to Diff 408437.Feb 14 2022, 8:35 AM
lntue marked 2 inline comments as done.

Add checks to make sure that clang-tidy is the same or newer than clang++ major version.

libc/CMakeLists.txt
68

I was trying to preserve the current behavior of using the HEAD clang-tidy when the new flag is not set, so that it won't break all current bots that do not have clang-tidy installed after submission.

libc/cmake/modules/LLVMLibCObjectRules.cmake
280–281

These dependencies are only needed for current behavior when clang-tidy is built in full build mode. If clang-tidy command is provided, we don't need these dependencies. Moreover, it might fail the build if these targets are not enabled with LLVM_ENABLE_PROJECTS.

lntue updated this revision to Diff 411294.Feb 24 2022, 7:38 PM

Remove legacy behavior with respect to full build.

sivachandra accepted this revision.Mar 1 2022, 1:28 AM
sivachandra added inline comments.
libc/CMakeLists.txt
75

Should this be EQUAL instead of LESS? For, we want clang-tidy version to match the clang-version to avoid header-mismatches.

82–84
The path to the clang-tidy binary can be set manually by passing
-DLLVM_LIBC_CLANG_TIDY=<path/to/clang-tidy> to CMake.

Similarly below as well.

88

Because this is a FATAL_ERROR, do we really have to set LLVM_LIBC_ENABLE_LINTING to OFF?

libc/cmake/modules/LLVMLibCObjectRules.cmake
230

Why is this required?

This revision is now accepted and ready to land.Mar 1 2022, 1:28 AM
lntue updated this revision to Diff 412094.Mar 1 2022, 7:08 AM

Address comments.

lntue marked 4 inline comments as done.Mar 1 2022, 7:10 AM