microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.46k stars 1.53k forks source link

Intellisense doesn't parse system includes correctly #12736

Closed nolankramer closed 2 days ago

nolankramer commented 4 days ago

Type: Bug

System includes are completely broken with clang and libstdc++. Intellisense claims std::filesystem::path is not a type, among other things.

This obviously causes a massive amount of "errors" to show up in the editor.

Here's my clang -v:

Ubuntu clang version 18.1.3 (1ubuntu1)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/13
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/13
Candidate multilib: .;@m64
Selected multilib: .;@m64

And my Linux configuration in c_cpp_properties.json:

{
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/clang++",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-clang-x64",
            "configurationProvider": "ms-vscode.cmake-tools"
        }

The std version being passed into the compile commands is: -std=gnu++17

Extension version: 1.21.6 VS Code version: Code 1.93.1 (38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40, 2024-09-11T17:20:05.685Z) OS version: Linux x64 6.8.0-45-generic snap Modes:

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 7 PRO 6850H with Radeon Graphics (16 x 2393)| |GPU Status|2d_canvas: unavailable_software
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: disabled_software
multiple_raster_threads: enabled_on
opengl: disabled_off
rasterization: disabled_software
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: disabled_software
video_encode: disabled_software
vulkan: disabled_off
webgl: unavailable_software
webgl2: unavailable_software
webgpu: disabled_off
webnn: disabled_off| |Load (avg)|2, 1, 2| |Memory (System)|14.89GB (7.96GB free)| |Process Argv|--no-sandbox --force-user-env --crash-reporter-id 0075ae52-00ae-4c27-9257-6ea0067d3b86| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|plasma| |XDG_CURRENT_DESKTOP|KDE| |XDG_SESSION_DESKTOP|KDE| |XDG_SESSION_TYPE|x11|
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vswsl492:30256859 vscod805cf:30301675 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 a9j8j154:30646983 962ge761:30959799 pythongtdpath:30769146 welcomedialogc:30910334 pythonnoceb:30805159 asynctok:30898717 pythonmypyd1:30879173 2e7ec940:31000449 pythontbext0:30879054 accentitlementst:30995554 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 g316j359:31013175 a69g1124:31058053 dvdeprecation:31068756 dwnewjupytercf:31046870 newcmakeconfigv2:31071590 impr_priority:31102340 nativerepl2:31139839 refactort:31108082 pythonrstrctxt:31112756 flightc:31134773 wkspc-onlycs-t:31132770 wkspc-ranged-c:31125598 pme_test_t:31118333 ei213698:31121563 iacca1:31138162 ```
Colengms commented 4 days ago

Hi @nolankramer . I'm not easily able to repro an issue with the configuration you provided (without the custom configuration provider specified), clang 18.1.3, and the following code:

#include <filesystem>

void foo()
{
    std::filesystem::path a;
}

However, your configuration does include:

"configurationProvider": "ms-vscode.cmake-tools"

So your IntelliSense configuration may be based on whatever CMake Tools has provided (which would require a CMakeLists.txt and have specified the source file there).

We are aware of the following issue with clang 18. You might try the work around here: https://github.com/microsoft/vscode-cpptools/issues/12618

nolankramer commented 4 days ago

Thanks for the reply @Colengms ! I tried the workaround, but no luck - same issues.

How can I provide more information about the CMake setup without pasting the CMakeLists.txt here, since the project is proprietary?

Is there specific CMake values you'd like to know about?

If it helps, here's the clang switches I see in the compile_commands.json: -g -fstandalone-debug -std=gnu++17

nolankramer commented 4 days ago

Interestingly, removing the "configurationProvider": "ms-vscode.cmake-tools" configuration value does fix the issue. Which makes me wonder what I could possibly be doing wrong in the CMakeLists.txt...

bobbrow commented 3 days ago

I tried the workaround, but no luck - same issues.

If you are using the configuration provider, I believe the workaround also required setting mergeConfigurations to true. However, we put the workaround into our main configurations starting in 1.22.4 so that it should hopefully apply globally to everyone without having to fiddle with configurations.

nolankramer commented 2 days ago

Yes it looks like setting mergeConfigurations to true fixes the issue when using the configuration provider.

This can be closed since there are now two solutions, with backend changes pending to ease setup.