llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.61k stars 11.82k forks source link

Make libc code lint clean #60984

Open sivachandra opened 1 year ago

sivachandra commented 1 year ago

After https://reviews.llvm.org/D144705, it is possible to run linting on the libc source code again. Because of the long time since we last did any formal lint checking, the source tree has regressed in a number of places with respect to code style. Also, the new LIBC_INLINE tag is missing in a number of places. This issue is about making the libc source lint clean so that we can start running linting on a CI builder.

Addressing this bug has to be a team effort as a large part of the source tree is affected. The best way to start doing the cleanup is this:

  1. Build Clang and Clang-Tidy from head and install it into a special directory, say ~/libc-lint-tools/. You will have to install the following targets: install-clang, install-clang-tidy, install-core-resource-headers, install-clang-resource-headers, install-builtins.
  2. Configure libc with:
    cmake -G Ninja ../llvm -DLLVM_ENABLE_PROJECTS="libc" -DCMAKE_BUILD_TYPE=Debug -DLLVM_LIBC_FULL_BUILD=ON
    -DCMAKE_CXX_COMPILER=~/libc-lint-tools/bin/clang++ -DCMAKE_C_COMPILER=~/libc-lint-tools/bin/clang
    -DLLVM_LIBC_CLANG_TIDY=~/libc-lint-tools/bin/clang-tidy 
  3. Build any lint target, for example, libc.src.string.strlen.__lint__ or just execute the libc-lint target. They should you a large number of lint problems.
  4. Send patches to problems identified in step 3.
llvmbot commented 1 year ago

@llvm/issue-subscribers-libc

sivachandra commented 1 year ago

FYI, we have a lint bot now connected to staging: https://lab.llvm.org/staging/#/builders/242