You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
clang-tidy fails on standalone headers with GCC cross-compiler predefines, but succeeds with compilation database #14815
VS Code 1.140.0, Ubuntu 22.04.5
C/C++ extension 1.34.4; bundled clang-tidy 23.1.0
CMake Tools 1.24.42; GCC 13.4.0 cross-compiler and its SDK libstdc++ headers
C++23 CMake project; CMAKE_EXPORT_COMPILE_COMMANDS=ON
C_Cpp.codeAnalysis.clangTidy.enabled=true and useBuildPath=true
c_cpp_properties.json sets compileCommands and uses the CMake Tools configuration provider
Bug Summary and Steps to Reproduce
Reproduction
Configure a C++23 CMake target containing a .cpp that includes a project .h. The header includes SDK C++ headers such as .
Confirm compile_commands.json has an entry for the .cpp, but none for the .h.
Open or save the header with automatic clang-tidy analysis enabled.
Compare this with analyzing the .cpp, or running bundled clang-tidy with -p .
Actual behavior
The extension analyzes the header using synthesized arguments after --, rather than -p. The logged command includes -std=gnu++23, SDK include paths, and hundreds of GCC predefined macros passed as -D__.... Clang-tidy reports errors in SDK libstdc++ headers involving _Float32, _Float64, and bf16, followed by too many errors emitted and Error while processing
. The .cpp analysis succeeds.
Replaying the logged header command fails. Replaying that same command with only GCC -D__.../-U__... arguments removed succeeds and still produces ordinary header diagnostics. Direct clang-tidy -p
also succeeds.
Expected behavior
Header analysis should use a compatible command associated with the including translation unit, or avoid passing GCC-only predefined macros as explicit arguments to Clang.
Impact
The processing error appears on headers after opening or saving them, despite successful project builds, and makes header diagnostics unreliable.
Activity