Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

clang-tidy doesn't recognize PCH format #25

Closed
mo-xiaoming opened this issue Mar 2, 2020 · 3 comments
Closed

clang-tidy doesn't recognize PCH format #25

mo-xiaoming opened this issue Mar 2, 2020 · 3 comments

Comments

@mo-xiaoming
Copy link
Contributor

Built with both ENABLE_CLANG_TIDY and DENABLE_PCH=ON enabled, clang-tidy threw errors about PCH format unrecognized

error: file '.../build/test/CMakeFiles/tests.dir/cmake_pch.hxx.gch' is not a valid precompiled PCH file [clang-diagnostic-error]
error: input is not a PCH file: '.../build/test/CMakeFiles/tests.dir/cmake_pch.hxx.gch' [clang-diagnostic-error]
2 errors generated.
Error while processing .../test/tests.cpp.
Found compiler error(s).
$ clang-tidy --version
LLVM (http://llvm.org/):
  LLVM version 9.0.0
  
  Optimized build.
  Default target: x86_64-pc-linux-gnu
  Host CPU: ivybridge

P.S. I tried to limit clang-tidy to specified targets, but PCH file implicitly included in all cpp files, so this way a dead end

@exief
Copy link

exief commented Mar 9, 2020

It's caused by gch being a gcc specific extension for pch files, clang expects it to be a .pch file not sure how to resolve this

@balintkissdev
Copy link

I saw your issue while I was also having this problem in my project and was scouring Google for help. If anyone else has this same issue with clang-tidy + pch + gcc, I found a workaround by generating the clang .pch as a custom command before making the real build with the gcc .gch.

https://gitlab.kitware.com/cmake/cmake/-/issues/22081#note_943104

IcyTv added a commit to IcyTv/Acorn that referenced this issue Feb 23, 2022
Added very basic support for clang-tidy. Currently it does not really
work (at least on windows) because the meson precompiled header file
is not recognized as such in clang-tidy. See
cpp-best-practices/gui_starter_template#25

It also apperantly ignores the regex, since vendor projects are checked...
@lefticus
Copy link
Member

A fix has been applied in https://github.com/cpp-best-practices/project_options to prevent PCH with GCC + clang-tidy being enabled at the same time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants