microsoft / microsoft/vscode-cmake-tools
Go to Definition on a function callsite goes to the header declaration instead of its implementation after upgrading vscode-cmake-tools from 1.7.3 to 1.8.1
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 546
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 32
Description
### Brief Issue Summary
When using `vscode-cpptools` version 1.6.0, Go to Definition on a function callsite goes to the header declaration instead of its implementation after upgrading `vscode-cmake-tools` from 1.7.3 to 1.8.1.
I am not sure if this issue belongs in this repo or `vscode-cpptools`, but let's start here.
I have a minimal embedded C project that I'm able to repro consistently against: https://github.com/aleun/cmake-cpp-repro. It is self-contained and includes the ARM GCC, CMake, and Ninja Windows binaries I used.
### Expected:
1. Clone repo https://github.com/aleun/cmake-cpp-repro
1. Open VS Code in `nxp` directory: `code nxp`
1. Open `main.c`
1. Put cursor on `run_foo`
1. Right Click -> Go to Definition
1. Cursor is now at `run_foo` definition in `foo.c`.

### Apparent Behavior:
1. Clone repo https://github.com/aleun/cmake-cpp-repro
1. Open VS Code in `nxp` directory: `code nxp`
1. Open `main.c`
1. Put cursor on `run_foo`
1. Right Click -> Go to Definition
1. Cursor is now at `run_foo` in `foo.h`, not `foo.c`.

### C/C++: Log Diagnostics Output
Here are the log outputs for both 1.7.3 and 1.8.1. `browsePath` is empty in the latter.
CMake Tools 1.7.3
```
-------- Diagnostics - 9/2/2021, 3:15:02 PM
Version: 1.6.0
Current Configuration:
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Preview\\VC\\Tools\\MSVC\\14.30.30423\\bin\\Hostx64\\x64\\cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64",
"compilerArgs": [],
"intelliSenseModeIsExplicit": false,
"cStandardIsExplicit": false,
"cppStandardIsExplicit": false,
"compilerPathIsExplicit": false,
"configurationProvider": "ms-vscode.cmake-tools",
"browse": {
"path": [
"${workspaceFolder}/**"
],
"limitSymbolsToIncludedHeaders": true
}
}
Custom browse configuration:
{
"browsePath": [
"c:/proj/cmake-cpp-repro/core",
"c:/proj/cmake-cpp-repro/nxp",
"c:/proj/cmake-cpp-repro/nxp/build/core/cmakefiles/core.dir"
],
"standard": "gnu99",
"compilerPath": "c:/proj/cmake-cpp-repro/nxp/artifacts/compilers/arm/gcc/2020.10.0/bin/arm-none-eabi-gcc.exe",
"compilerArgs": [
"--specs=nano.specs",
"-ffunction-sections",
"-fdata-sections",
"-fno-strict-aliasing",
"-fno-builtin",
"-fshort-enums",
"-Wall",
"-Wextra",
"-Wuninitialized",
"-Wdouble-promotion",
"-Werror",
"-Wno-unused-parameter",
"-O0",
"-g3",
"-std=gnu99"
]
}
Custom configurations:
[ C:\proj\cmake-cpp-repro\nxp\main.c ]
{
"defines": [],
"standard": "gnu99",
"includePath": [
"c:/proj/cmake-cpp-repro/nxp",
"c:/proj/cmake-cpp-repro/core"
],
"compilerPath": "c:/proj/cmake-cpp-repro/nxp/artifacts/compilers/arm/gcc/2020.10.0/bin/arm-none-eabi-gcc.exe",
"compilerArgs": [
"--specs=nano.specs",
"-ffunction-sections",
"-fdata-sections",
"-fno-strict-aliasing",
"-fno-builtin",
"-fshort-enums",
"-Wall",
"-Wextra",
"-Wuninitialized",
"-Wdouble-promotion",
"-Werror",
"-Wno-unused-parameter",
"-O0",
"-g3",
"-std=gnu99"
]
}
Translation Unit Mappings:
[ C:\proj\cmake-cpp-repro\nxp\main.c ]:
C:\PROJ\CMAKE-CPP-REPRO\NXP\MAIN.C
Translation Unit Configurations:
[ C:\proj\cmake-cpp-repro\nxp\main.c ]:
Process ID: 29208
Memory Usage: 13 MB
Compiler Path: c:/proj/cmake-cpp-repro/nxp/artifacts/compilers/arm/gcc/2020.10.0/bin/arm-none-eabi-gcc.exe
Includes:
C:\PROJ\CMAKE-CPP-REPRO\NXP
C:\PROJ\CMAKE-CPP-REPRO\CORE
C:\PROJ\CMAKE-CPP-REPRO\NXP\ARTIFACTS\COMPILERS\ARM\GCC\2020.10.0\ARM-NONE-EABI\INCLUDE\NEWLIB-NANO
C:\PROJ\CMAKE-CPP-REPRO\NXP\ARTIFACTS\COMPILERS\ARM\GCC\2020.10.0\LIB\GCC\ARM-NONE-EABI\10.2.1\INCLUDE
C:\PROJ\CMAKE-CPP-REPRO\NXP\ARTIFACTS\COMPILERS\ARM\GCC\2020.10.0\LIB\GCC\ARM-NONE-EABI\10.2.1\INCLUDE-FIXED
C:\PROJ\CMAKE-CPP-REPRO\NXP\ARTIFACTS\COMPILERS\ARM\GCC\2020.10.0\ARM-NONE-EABI\INCLUDE
Standard Version: c99
IntelliSense Mode: windows-gcc-arm
Other Flags:
--gcc
--gnu_version=100201
Total Memory Usage: 13 MB
------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 13788
```
CMake Tools 1.8.1
```
-------- Diagnostics - 9/2/2021, 3:13:50 PM
Version: 1.6.0
Current Configuration:
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Preview\\VC\\Tools\\MSVC\\14.30.30423\\bin\\Hostx64\\x64\\cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64",
"compilerArgs": [],
"intelliSenseModeIsExplicit": false,
"cStandardIsExplicit": false,
"cppStandardIsExplicit": false,
"compilerPathIsExplicit": false,
"configurationProvider": "ms-vscode.cmake-tools",
"browse": {
"path": [
"${workspaceFolder}/**"
],
"limitSymbolsToIncludedHeaders": true
}
}
Custom browse configuration:
{
"browsePath": []
}
Custom configurations:
[ C:\proj\cmake-cpp-repro\nxp\main.c ]
{
"defines": [],
"standard": "gnu99",
"includePath": [
"c:/proj/cmake-cpp-repro/nxp",
"c:/proj/cmake-cpp-repro/core"
],
"compilerPath": "c:/proj/cmake-cpp-repro/nxp/artifacts/compilers/arm/gcc/2020.10.0/bin/arm-none-eabi-gcc.exe",
"compilerArgs": [
"--specs=nano.specs",
"-ffunction-sections",
"-fdata-sections",
"-fno-strict-aliasing",
"-fno-builtin",
"-fshort-enums",
"-Wall",
"-Wextra",
"-Wuninitialized",
"-Wdouble-promotion",
"-Werror",
"-Wno-unused-parameter",
"-O0",
"-g3",
"-std=gnu99"
]
}
Translation Unit Mappings:
[ C:\proj\cmake-cpp-repro\nxp\main.c ]:
C:\PROJ\CMAKE-CPP-REPRO\NXP\MAIN.C
Translation Unit Configurations:
[ C:\proj\cmake-cpp-repro\nxp\main.c ]:
Process ID: 8724
Memory Usage: 13 MB
Compiler Path: c:/proj/cmake-cpp-repro/nxp/artifacts/compilers/arm/gcc/2020.10.0/bin/arm-none-eabi-gcc.exe
Includes:
C:\PROJ\CMAKE-CPP-REPRO\NXP
C:\PROJ\CMAKE-CPP-REPRO\CORE
C:\PROJ\CMAKE-CPP-REPRO\NXP\ARTIFACTS\COMPILERS\ARM\GCC\2020.10.0\ARM-NONE-EABI\INCLUDE\NEWLIB-NANO
C:\PROJ\CMAKE-CPP-REPRO\NXP\ARTIFACTS\COMPILERS\ARM\GCC\2020.10.0\LIB\GCC\ARM-NONE-EABI\10.2.1\INCLUDE
C:\PROJ\CMAKE-CPP-REPRO\NXP\ARTIFACTS\COMPILERS\ARM\GCC\2020.10.0\LIB\GCC\ARM-NONE-EABI\10.2.1\INCLUDE-FIXED
C:\PROJ\CMAKE-CPP-REPRO\NXP\ARTIFACTS\COMPILERS\ARM\GCC\2020.10.0\ARM-NONE-EABI\INCLUDE
Standard Version: c99
IntelliSense Mode: windows-gcc-arm
Other Flags:
--gcc
--gnu_version=100201
Total Memory Usage: 13 MB
```
### Platform and Versions
- **Operating System**: Windows 10
- **CMake Version**: 3.20.0
- **VSCode Version**: 1.60.0
- **CMake Tools Extension Version**: 1.8.1
- **Ninja Version**: 1.10.2
- **Compiler/Toolchain**: `arm-none-eabi-gcc.exe (GNU Arm Embedded Toolchain 10-2020-q4-major) 10.2.1 20201103 (release)`
```
// Output of VS Code Help > About page:
Version: 1.60.0 (user setup)
Commit: e7d7e9a9348e6a8cc8c03f877d39cb72e5dfb1ff
Date: 2021-09-01T10:41:52.311Z
Electron: 13.1.8
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19043
```
```
$ code --list-extensions --show-versions | rg "cmake|cpp"
ms-vscode.cmake-tools@1.8.1
ms-vscode.cpptools@1.6.0
twxs.cmake@0.0.17
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked cmake-cpp-repro project, opening nxp/main.c and comparing Go to Definition for run_foo under CMake Tools 1.7.3 and 1.8.1. Review the supplied C/C++ diagnostics, especially the change from populated browsePath entries to an empty browsePath; done means the callsite resolves to foo.c rather than foo.h.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cmake, cpp, vscode
- Domain
- build-system, developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100