Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creation declaration/definition anonymous namespace in created definition #10189

Closed
khlebnikov opened this issue Nov 25, 2022 · 5 comments
Closed
Assignees
Labels
bug Feature: Create Declaration or Definition fixed Check the Milestone for the release in which the fix is or will be available. Language Service Visual Studio Inherited from Visual Studio
Milestone

Comments

@khlebnikov
Copy link

khlebnikov commented Nov 25, 2022

Environment

  • OS and Version: Windows 10
  • VS Code Version: 1.73.1
  • C/C++ Extension Version: 1.13.4

Bug Summary and Steps to Reproduce

  1. Create a single .cpp file with the following contents:
namespace n1 {

namespace {

class C {
    void f();
    void g();
};

}

void C::f()
{
}

}
  1. Left-click on g and choose Create Declaration / Definition.

  2. This results in the following output:

namespace n1 {

namespace {

class C {
    void f();
    void g();
};

}

void C::f()
{
}

void `anonymous-namespace'::C::g()
{
}

}

Expected behavior

`anonymous-namespace'::

should not be part of the function definition.

Code sample and Logs

No c_cpp_properties.json.

C/C++: Log Diagnostics:

-------- Diagnostics - 11/25/2022, 1:55:36 PM
Version: 1.13.4
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "windowsSdkVersion": "10.0.19041.0",
    "compilerPath": "C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.34.31933/bin/Hostx64/x64/cl.exe",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "windows-msvc-x64",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPathIsExplicit": false,
    "browse": {
        "path": [
            "${workspaceFolder}/**"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
Translation Unit Mappings:
[ C:\temp\test.cpp ]:
    C:\temp\test.cpp
Translation Unit Configurations:
[ C:\temp\test.cpp ]:
    Process ID: 28824
    Memory Usage: 12 MB
    Compiler Path: C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64\cl.exe
    Includes:
        C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.34.31933\include
        C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.34.31933\atlmfc\include
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\winrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\cppwinrt
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: ms_c++17
    IntelliSense Mode: windows-msvc-x64
Total Memory Usage: 12 MB

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

C/C++ Output:

loggingLevel: Debug
loggingLevel has changed to: Debug
cpptools/didChangeCppProperties
cpptools/getCodeActions: C:\temp\test.cpp (id: 31)
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/activeDocumentChange: C:\temp\test.cpp
cpptools/getFoldingRanges: C:\temp\test.cpp (id: 32)
cpptools/getCodeActions: C:\temp\test.cpp (id: 33)
idle loop: reparsing the active document
Checking for syntax errors: C:\temp\test.cpp
Queueing IntelliSense update for files in translation unit of: C:\temp\test.cpp
cpptools/finishUpdateSquiggles
Error squiggle count: 0
Update IntelliSense time (sec): 0.253
cpptools/getSemanticTokens: C:\temp\test.cpp (id: 34)
cpptools/getFoldingRanges: C:\temp\test.cpp (id: 35)
textDocument/hover: C:\temp\test.cpp (id: 36)
cpptools/getCodeActions: C:\temp\test.cpp (id: 37)
textDocument/hover: C:\temp\test.cpp (id: 38)
cpptools/getCodeActions: C:\temp\test.cpp (id: 39)
cpptools/createDeclDef: C:\temp\test.cpp (id: 40)
textDocument/didChange: C:\temp\test.cpp
cpptools/textEditorSelectionChange
cpptools/getDocumentSymbols: C:\temp\test.cpp (id: 41)
cpptools/getDocumentSymbols
cpptools/getFoldingRanges: C:\temp\test.cpp (id: 42)
cpptools/getCodeActions: C:\temp\test.cpp (id: 43)
cpptools/getInlayHints: C:\temp\test.cpp (id: 44)
cpptools/getSemanticTokens: C:\temp\test.cpp (id: 45)
idle loop: reparsing the active document
Checking for syntax errors: C:\temp\test.cpp
Queueing IntelliSense update for files in translation unit of: C:\temp\test.cpp
sending 1 changes to server
cpptools/finishUpdateSquiggles
Error squiggle count: 3
cpptools/getFoldingRanges: C:\temp\test.cpp (id: 46)
Checking for syntax errors: C:\temp\test.cpp
Queueing IntelliSense update for files in translation unit of: C:\temp\test.cpp
  tag parsing file: C:\temp\test.cpp
    tag parsing error (this can be ignored unless symbols can't be found):
    line 16 (col. 6): error: unrecognized token
    line 16 (col. 26): error: missing closing quote
cpptools/finishUpdateSquiggles
Error squiggle count: 3
Update IntelliSense time (sec): 2.253
cpptools/getSemanticTokens: C:\temp\test.cpp (id: 47)
cpptools/getCodeActions: C:\temp\test.cpp (id: 48)
cpptools/getFoldingRanges: C:\temp\test.cpp (id: 49)

Screenshots

No response

Additional context

No response

@bobbrow
Copy link
Member

bobbrow commented Nov 30, 2022

This bug also reproduces in Visual Studio. Since we share the code with that implementation, we also inherited this bug. Thanks again for reporting it. The workaround for now is to delete the 'anonymous-namespace':: part.

@khlebnikov
Copy link
Author

No worries! (And yes, the workaround is trivial :)) Thank you for your great work!

@bobbrow bobbrow modified the milestones: Tracking, 1.14 Jan 11, 2023
@sean-mcmanus sean-mcmanus modified the milestones: 1.14, 1.14.1 Jan 21, 2023
@sean-mcmanus sean-mcmanus added the fixed Check the Milestone for the release in which the fix is or will be available. label Jan 25, 2023
@sean-mcmanus
Copy link
Contributor

A fix is available with 1.14.1 (pre-release): https://github.com/microsoft/vscode-cpptools/releases/tag/v1.14.1

@H-G-Hristov
Copy link

I am on 1.14.1 (pre-release). I tried the feature:

  1. Pointed to the three dots under a constructor in a header file
  2. Clicked on Quick fix
  3. Selected the option to create the definition
    Nothing happens and I also don't see any messages in the C++ log.

@sean-mcmanus
Copy link
Contributor

@H-G-Hristov Those repro steps are different from this bug (which I've verified as fixed) so I've created a new issue to track that #10463 .

@github-actions github-actions bot locked and limited conversation to collaborators Apr 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Feature: Create Declaration or Definition fixed Check the Milestone for the release in which the fix is or will be available. Language Service Visual Studio Inherited from Visual Studio
Projects
None yet
Development

No branches or pull requests

5 participants