Skip to content

Instantly share code, notes, and snippets.

@sh-zam
Last active February 15, 2021 14:42
Show Gist options
  • Save sh-zam/a959ebc6fd21efcdebd22352ff36fad2 to your computer and use it in GitHub Desktop.
Save sh-zam/a959ebc6fd21efcdebd22352ff36fad2 to your computer and use it in GitHub Desktop.

Building clang-tidy

  • cd to llvm-project and then run cmake.
cmake -B build -G Ninja -DLLVM_ENABLE_PROJECTS="clang-tools-extra;clang" \
      -DLLVM_TARGET_ARCH="x86_64" -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
      -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_BUILD_TYPE=Release ./llvm

Note: building in Debug mode causes SERIOUS paging issues.

Running checker on full source

  1. Set PATH or use the option in script for clang-tidy binary
  2. Get compilation database using cmake and link it to project root.
  3. Run clang-tidy on project using helper script in llvm-project

    Script is Located here: llvm-project/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

    ~/workspace/llvm-project/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py \
        -checks='-*,misc-no-key-function' -header-filter='.*'
        

    I got lots of errors while it checked moc_*. I am not sure how to go about fixing them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment