clang-tidy: How to suppress warnings?

后端 未结 4 1816
抹茶落季
抹茶落季 2020-12-30 04:02

I recently started experimenting with the clang-tidy tool of llvm. Now I am trying to suppress false warnings from third party library code. For this I want to

4条回答
  •  失恋的感觉
    2020-12-30 04:47

    Use -isystem instead of -I to set your system and 3rd party include paths. -I should only be used to include code that is part of the project being built.

    This is the only thing required to make clang-tidy ignore all errors in external code. All the other answers (at the point of writing) are just poor workarounds for something that is perfectly solved with -isystem.

    If you use a build system like CMake or Meson it will automatically set -I and -isystem correctly for you.

    -isystem is also the mechanism that is used for telling compilers, at least GCC and Clang, what's not your code. If you start to use -isystem you can also enable more compiler warnings without getting "false positives" from external code.

提交回复
热议问题