Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codechecker adding '-Wno-deprecated' causes clang-tidy to fail, when used with precompiled headers #4183

Open
invy opened this issue Mar 6, 2024 · 1 comment
Labels
analyzer 📈 Related to the analyze commands (analysis driver) clang-tidy 🐉 clang-tidy is a clang-based C++ “linter” tool.

Comments

@invy
Copy link

invy commented Mar 6, 2024

Describe the bug
After CodeChecker update I've been getting clang-diagnostic-errors reports by clang-tidy:

1 error generated.
Error while processing /path/to/my/code.cpp.
error: __DEPRECATED predefined macro was enabled in PCH file but is currently disabled [clang-diagnostic-error]
Found compiler error(s).

CodeChecker version
CodeChecker Version 6.23.1

To Reproduce
Steps to reproduce the behaviour:

To reproduce the behavior create add precompiled header into your cmake project:

  1. Create CMake Projejct...
add_executable(mytarget main.cpp)
target_precompile_headers(mytarget PRIVATE some_header_file.h)
add_compile_options(-Wdeprecated)
  1. Scan/Analyze with clang-tidy enabled. (Standard options)
  2. See error

Description
I've looked into the warning flags, CodeChecker passes to the clang-tidy and found one in particular "-Wno-deprecated"
The flag has a side-effect, it removes a preprocessor definition, __DEPRECATED, which was added in my CMake Project.

https://clang.llvm.org/docs/ClangCommandLineReference.html

-Wdeprecated, -Wno-deprecated[¶](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-Wdeprecated)

Enable warnings for deprecated constructs and define __DEPRECATED
@whisperity
Copy link
Member

whisperity commented Mar 6, 2024

Just for confirmation, could you please run an analysis but pass --enable clang-diagnostic-deprecated to CodeChecker analyze? It should turn that diagnostic flag back on, and thus side-step the problem. The issue is that warning flags need to be transformed, otherwise Tidy will emit Sema-level diagnostics as-if (in format) they were Tidy checkers...

(The fact that warning flags potentially change the behaviour of the code is a whole other can of worms...)

@whisperity whisperity added analyzer 📈 Related to the analyze commands (analysis driver) clang-tidy 🐉 clang-tidy is a clang-based C++ “linter” tool. labels Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer 📈 Related to the analyze commands (analysis driver) clang-tidy 🐉 clang-tidy is a clang-based C++ “linter” tool.
Projects
None yet
Development

No branches or pull requests

2 participants