Skip to content

'Create definition' was mistakenly inserted into a function-try-block #11216

Open
@ReadWriteV

Description

@ReadWriteV

Environment

  • OS and Version: Windows_NT x64 10.0.22621
  • VS Code Version: 1.80.1
  • C/C++ Extension Version: 1.16.3
  • If using SSH remote, specify OS of remote machine: No

Bug Summary and Steps to Reproduce

Bug Summary:

Steps to reproduce:

  1. Create test.h and test.cpp

test.h

class test
{
public:
    test(int v);
    int get_data();
private:
    int data;
};

test.cpp

#include "test.h"

test::test(int v)
try : data{v}
{
    // no exception
}
catch (...)
{
     // got an exception
}
  1. Go to test.h, Click on ''Create definition of get_data in test.cpp"
  2. See Incorrect creation of get_data in test.cpp
#include "test.h"

test::test(int v)
try : data{v}
{
    // no exception
}
int test::get_data()
{
    return 0;
}
catch (...)
{
    // got an exception
}

Expected behavior:
It should create definition of get_data after catch block

#include "test.h"

test::test(int v)
try : data{v}
{
    // no exception
}
catch (...)
{
    // got an exception
}

int test::get_data()
{
    return 0;
}

Configuration and Logs

-------- Diagnostics - 7/19/2023, 4:40:33 PM
Version: 1.16.3
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "d:\\Projects\\create_def/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "windowsSdkVersion": "10.0.22000.0",
    "compilerPath": "cl.exe",
    "compilerPathInCppPropertiesJson": "cl.exe",
    "cStandard": "c17",
    "cppStandard": "c++20",
    "intelliSenseMode": "windows-msvc-x64",
    "intelliSenseModeIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "mergeConfigurations": false,
    "compilerPathIsExplicit": false,
    "configurationProvider": "ms-vscode.cmake-tools",
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Custom browse configuration: 
{
    "browsePath": [
        "d:/projects/create_def/build/cmakefiles",
        "d:/projects/create_def/build/cmakefiles/15cc6f65a7308b0862ae99be79b970bb",
        "d:/projects/create_def"
    ],
    "compilerPath": "c:/program files (x86)/microsoft visual studio/2022/buildtools/vc/tools/msvc/14.36.32532/bin/hostx64/x64/cl.exe",
    "compilerArgs": [],
    "compilerFragments": [
        "/DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1"
    ]
}
Custom configurations:
[ D:\Projects\create_def\main.cpp ]
{
    "includePath": [],
    "defines": [],
    "compilerPath": "c:/program files (x86)/microsoft visual studio/2022/buildtools/vc/tools/msvc/14.36.32532/bin/hostx64/x64/cl.exe",
    "compilerArgs": [],
    "compilerFragments": [
        "/DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1"
    ]
}
cpptools version (native): 1.16.3.0
Translation Unit Mappings:
[ D:\Projects\create_def\main.cpp ]:
    D:\Projects\create_def\main.cpp
    D:\Projects\create_def\test.h *
Translation Unit Configurations:
[ D:\Projects\create_def\main.cpp ]:
    Process ID: 14888
    Memory Usage: 120 MB
    Compiler Path: C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\bin\Hostx64\x64\cl.exe
    Includes:
        C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\include
        C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\atlmfc\include
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\um
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\ucrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\shared
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\winrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\cppwinrt
    Defines:
        WIN32
        _WINDOWS
    Standard Version: ms_c++14
    IntelliSense Mode: windows-msvc-x64
    Other Flags:
        --rtti
Total Memory Usage: 120 MB

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

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions