microsoft / microsoft/vscode-cpptools

IntelliSenseinclude paths not updated after generated code using compileCommands

Open
#10,854 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Feature: Compile Commands Feature: Configuration Language Service
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: Ubuntu 18.04
  • VS Code Version: 1.77.3
  • C/C++ Extension Version: v1.14.5
  • If using SSH remote, specify OS of remote machine: N/A
Bug Summary and Steps to Reproduce

Bug Summary:

Our project utilizes Bazel and uses a tool to generate a compile_commands.json file that is intended to be used by the C/C++ IntelliSense engine. In many cases, the paths to the header files in the compile_commands.json reference folders within the Bazel build tree known as "virtual includes", which are symlinks to the actual headers. However, the "virtual includes" folders aren't created until a build is performed.

The issue at hand is that if the compile_commands.json is generated before the folders it references are created, then it's not possible to coerce IntelliSense to re-evaluate the includes for a given translation unit without re-generating the compile_commands.json file. Even using the C/C++: Reset IntelliSense Database or C/C++: Restart IntelliSense for Active file commands do not cause it to re-evaluate the include paths.

As it stands, the only way we've been able to get IntelliSense to recognize the generated folders is to generate the compile_commands.json file after the folders have been generated.

Steps to reproduce:

  1. Generate a compile_commands.json file for a project that has includes in folders which are not yet created
  2. Open a .cpp file that includes a file from a path that has yet to be generated
  3. IntelliSense will show red squiggles for the include file that is not yet available
  4. Generate the missing file
  5. Close/re-open the file or run the C/C++: Reset IntelliSense Database or C/C++: Restart IntelliSense for Active file commands
  6. IntelliSense will continue to show red squiggles for the include file that is now available
  7. Re-generate the compile_commands.json file (or use the Linux touch command to update the file times)
  8. IntelliSense will now re-process the includes and remove the red squiggles

Expected behavior:

The compile_commands.json should not have to be re-generated (or updated) in order to cause IntelliSense to discover include paths which were not present when the source code file was initially parsed by IntelliSense. CLosing/re-opening or using the C/C++: Reset IntelliSense Database or C/C++: Restart IntelliSense for Active file commands should trigger this re-evaluation.

Configuration and Logs
{
    "configurations": [
        {
            "name": "gcc9-x86_64",
            "compilerPath": "${workspaceFolder}/external/cc_toolchain_linux-linux-gcc9-x86_64-linux_ubuntu_focal-x86_64/toolchain/usr/bin/x86_64-linux-gnu-gcc-9",
            "cStandard": "${default}",
            "cppStandard": "${default}",
            "compileCommands": "${default}"
        }
    ],
    "version": 4
}
Other Extensions

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are named. Start by tracing how compile_commands.json is processed and how the C/C++: Reset IntelliSense Database and C/C++: Restart IntelliSense for Active file commands trigger re-evaluation, then reproduce the generated-include sequence. Done means closing, reopening, or resetting IntelliSense discovers newly created include paths without touching compile_commands.json.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, typescript
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.