microsoft / vscode-cpptools

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

Errors Related to Variable Definition Location and Colorization under WSL #11733

Open mobsceneZ opened 1 year ago

mobsceneZ commented 1 year ago

Environment

Bug Summary and Steps to Reproduce

Bug Summary:

  1. Some variables defined in the code body of a C Macros are not colorized but others are.
  2. When clicking 'Go to Definition' on variables defined within the C Macros, it shows No definition found.

Steps to reproduce:

  1. Start up WSL in Windows Terminal, create a directory named issue;
  2. Open this directory in VSCode by switching to it and typing code .;
  3. Create a new file name poc.c, and copy following content:
    
    #include <time.h>
    #include <stdio.h>
    #include <stdlib.h>

define NOP(block) \

do {                \
    {block}         \
} while (0);

typedef struct { int a; double b; } test;

int main(void) { NOP({ test v1; v1.a = 10;

    for (int i = 0; i < 10; i++) {
        if (rand() % 2) {
            test v2;
        }
    }
})

}

5. See the first bug:
![捕获](https://github.com/microsoft/vscode-cpptools/assets/33396195/f40a9d75-c663-4118-b691-e1eba4764908)
7. See the second bug:
![捕获](https://github.com/microsoft/vscode-cpptools/assets/33396195/260e3d42-333a-412b-b218-43d393aacddf)

Expected behavior:
1. At least all the type keywords of variables are colorized;
2. 'Go to Definition' points to the correct variable definition location;

### Configuration and Logs

```shell
{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/local/bin/clang",
            "cStandard": "c17",
            "cppStandard": "c++14",
            "intelliSenseMode": "linux-clang-x64"
        }
    ],
    "version": 4
}

-------- Diagnostics - 11/22/2023, 9:04:19 PM
Version: 1.18.5
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "/home/lain/issue/**"
    ],
    "defines": [],
    "compilerPath": "/usr/local/bin/clang",
    "cStandard": "c17",
    "cppStandard": "c++14",
    "intelliSenseMode": "linux-clang-x64",
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compilerPathInCppPropertiesJson": "/usr/local/bin/clang",
    "mergeConfigurations": false,
    "browse": {
        "path": [
            "/home/lain/issue/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
cpptools version (native): 1.18.3.0
Translation Unit Mappings:
[ /home/lain/issue/poc.c ]:
    /home/lain/issue/poc.c
Translation Unit Configurations:
[ /home/lain/issue/poc.c ]:
    Process ID: 13842
    Memory Usage: 11 MB
    Compiler Path: /usr/local/bin/clang
    Includes:
        /home/lain/.wasmedge/include
        /usr/local/lib/clang/13.0.0/include
        /usr/local/include
        /usr/include/x86_64-linux-gnu
        /usr/include
    Standard Version: c17
    IntelliSense Mode: linux-clang-x64
    Other Flags:
        --clang
        --clang_version=130000
Total Memory Usage: 11 MB

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

Other Extensions

No response

Additional context

No response

sean-mcmanus commented 1 year ago

I've filed a bug on VS (shared component) at https://developercommunity.visualstudio.com/t/CC-go-to-def-and-semantic-colorizatio/10523632 .