Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

clang-tidy fails on standalone headers with GCC cross-compiler predefines, but succeeds with compilation database

未关闭
#14,815 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
cmake, cpp, typescript, vscode

调研方向

Start with the attached clang-tidy_log.txt and compare the synthesized header command against compile_commands.json for the including .cpp file. Reproduce the C++23 CMake project case, then verify that header analysis succeeds without the reported GCC predefined-macro errors while still producing ordinary header diagnostics.

由索引模型根据 Issue 内容生成。

描述

Environment

Environment

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

  1. Configure a C++23 CMake target containing a .cpp that includes a project .h. The header includes SDK C++ headers such as .
  2. Confirm compile_commands.json has an entry for the .cpp, but none for the .h.
  3. Open or save the header with automatic clang-tidy analysis enabled.
  4. 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.

clang-tidy_log.txt

Configuration and Logs
{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/g++",
            "cStandard": "c11",
            "cppStandard": "c++23",
            "intelliSenseMode": "gcc-x64",
            "compileCommands": "${workspaceFolder}/compile_commands.json",
            "configurationProvider": "ms-vscode.cmake-tools"
        }
    ],
    "version": 4
}
Other Extensions

No response

Additional context

No response

主要语言
TypeScript
星标
6.2k
派生
1.7k
平均合并
20 小时 53 分钟
30 天内合并 PR
41

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/vscode-cpptools 的其他 Issue

查看 microsoft/vscode-cpptools 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。