microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.43k stars 430 forks source link

C++ Intellisense broken in some files, but working in other files #3718

Open GEOEGII555 opened 2 months ago

GEOEGII555 commented 2 months ago

Brief Issue Summary

When setting this extension as a configuration provider, Intellisense breaks in specific files, but works fine in other files.

CMake Tools Diagnostics

-------- Diagnostics - 4/23/2024, 11:43:16 AM
Version: 1.19.9
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "f:/Code/MNComputers/emulator/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "windowsSdkVersion": "10.0.22621.0",
    "compilerPath": "cl.exe",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "windows-msvc-x64",
    "compilerPathInCppPropertiesJson": "cl.exe",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPathIsExplicit": false,
    "configurationProvider": "ms-vscode.cmake-tools",
    "browse": {
        "path": [
            "f:/Code/MNComputers/emulator/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Custom browse configuration: 
{
    "browsePath": [
        "c:/program files (x86)/sockpp/include",
        "f:/code/mncomputers/emulator"
    ],
    "compilerPath": "c:/program files/microsoft visual studio/2022/community/vc/tools/msvc/14.39.33519/bin/hostx86/x64/cl.exe",
    "compilerArgs": [],
    "compilerFragments": [
        "/DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1",
        "/ZI",
        "/DEBUG:FULL"
    ]
}
cpptools version (native): 1.19.9.0
Translation Unit Mappings:
[ F:\Code\MNComputers\emulator\emulator.cpp - source TU]:
Translation Unit Configurations:
[ F:\Code\MNComputers\emulator\emulator.cpp ]:
    Process ID: 25216
    Memory Usage: 39 MB
    Compiler Path: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\Hostx86\x64\cl.exe
    Includes:
        C:\Program Files (x86)\sockpp\include
        C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include
        C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\atlmfc\include
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\cppwinrt
    Defines:
        WIN32
        _WINDOWS
        EBUG:FULL
    Standard Version: ms_c++17
    IntelliSense Mode: windows-msvc-x64
    Other Flags:
        --rtti
Total Memory Usage: 39 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 5112

Debug Log

No response

Additional Information

https://github.com/microsoft/vscode-cmake-tools/assets/57674559/0fde08db-f8b2-4177-aefc-ed39837f971c

GEOEGII555 commented 2 months ago

I've tried a couple of things, and it seems like the files which are specifically mentioned in CMakeLists.txt have intellisense disabled. All other files work fine. Here's a video where I edit CMakeLists.txt and show how the behavior changes: https://1drv.ms/v/s!As9AgYSaPCSsqn1JkngIrVQHJ-uB?e=iJrBom

GEOEGII555 commented 2 months ago

After some testing, I also found a second condition: the file must be mentioned in CMakeLists.txt, AND there should be an argument /DEBUG:FULL added via add_compile_options.

Somehow, /DEBUG:FULL is breaking intellisense. This only happens when vscode-cmake-tools is configured as the config provider, so it's probably a bug in this extension.

https://1drv.ms/v/s!As9AgYSaPCSsqn4cPDg38nFgkuGU?e=TOrb4h

v-frankwang commented 2 months ago

@GEOEGII555 In order to better solve your problem, we need more information from you, such as a project that can reproduce this issue and some screenshots? Thank you!

GEOEGII555 commented 2 months ago

Here: project.zip

v-frankwang commented 2 months ago

Thank you very much for your reply, I still can't reproduce the problem using the program you provided!

Here are my steps: repro2

GEOEGII555 commented 2 months ago

The CMake configuration has failed (bottom right corner), probably because CMake wasn't able to find sockpp. The issue seems to happen only after a successful CMake configuration.

I removed sockpp from CMakeLists.txt (commented out) and the issue is still present after this. Here's a zip archive with the same project (but with sockpp dependency removed, the issue is still present)

code.zip

GEOEGII555 commented 2 months ago

https://1drv.ms/v/s!As9AgYSaPCSsqwn4Y980H5UCv2ud?e=xVcRbs here's a 0.5 GB 7 minute long video of me showing this issue and how it only happens with MSVC and not GCC

v-frankwang commented 1 month ago

@GEOEGII555 Thank you very much for your reply, I watched the video you provided carefully and still not could not reproduce your problem after a successful configuration. Is it possible that I am not doing it correctly?

Here are my steps:

repro3

GEOEGII555 commented 1 month ago

@GEOEGII555 Thank you very much for your reply, I watched the video you provided carefully and still not could not reproduce your problem after a successful configuration. Is it possible that I am not doing it correctly?

Here are my steps:

repro3

The other steps do seem correct, however, I see you have "clang (visual studio...)" and just "visual studio ...", and you chose the first one. Can you try choosing the other one which just says Visual Studio ...? because it's the way how it shows up for me

v-frankwang commented 1 month ago

@gcampbell-msft I reproduced the issue based on the user's reply, and as the user said the issue only reproduces in certain files. It does not reproduce when my compiler of choice is clang.exe. Do we need to change the status of this issue to bug?

ENV: VS Code: 1.89.1 CMake tools: 1.18.38 C/C++:1.20.5

Repro steps recording:

Download the project: code.zip and open it in vscode. Run the "CMake: Select a Kit" command. Select "Visual studio xxx -amd64". Open broken.cpp file. On the eleventh line type “this ->

Actual results: issue 3718