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

Jump to macro definition failed when expanding macros with length around 2400. #4306

Closed
smwikipedia opened this issue Sep 23, 2019 · 9 comments
Labels
bug Feature: Go to Definition An issue related to Go to Definition/Declaration. 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

@smwikipedia
Copy link

smwikipedia commented Sep 23, 2019

Type: LanguageService

Describe the bug

  • OS and Version:
    Windows 10 Version 1709

  • VS Code Version:
    Version: 1.38.1 (user setup)
    Commit: b37e54c98e1a74ba89e03073e5a3761284e3ffb0
    Date: 2019-09-11T13:35:15.005Z
    Electron: 4.2.10
    Chrome: 69.0.3497.128
    Node.js: 10.11.0
    V8: 6.9.427.31-electron.0
    OS: Windows_NT x64 10.0.16299

  • C/C++ Extension Version:
    0.25.1

  • Other extensions you installed (and if the issue persists after disabling them):

  • A clear and concise description of what the bug is.
    Open this repo in VS Code:
    https://github.com/smwikipedia/macroExpansion

There are 2 files in that repo:

  • a.h: defines a bunch of macros
  • a.c: use the macros defined in a.h

In a.c file, line 7 to line 33 are some macros. See below:
image

Jump to definition for ztest_test_suite on line 7 in a.c. It will jump to struct unit_test in a.h at line 1. This is incorrect. See below:

image

So this issue seems to be related to the length of the macro expansion result. So I tried deleting single arbitrary line from a.c between line 8 and line 32.
Repeat jump to definition for ztest_test_suite on line 7 in a.c again. It will jump to #define ztest_test_suite(suite, ...) at line 31 in a.h. This is the correct result. See below:

image

The final macro expansion length is about 2400. It doesn't exceed the 20000 token length limitation. However, even if I changed to "editor.maxTokenizationLineLength": 50000 in the settings.json. The issue still remains.

image

@smwikipedia smwikipedia changed the title [c_cpp] Jump to macro definition failed when expanding macros with length around 2400. Jump to macro definition failed when expanding macros with length around 2400. Sep 24, 2019
@sean-mcmanus sean-mcmanus added bug Feature: Go to Definition An issue related to Go to Definition/Declaration. Language Service verified Bug has been reproduced Works in VS So we'd need to fix it for VS Code to reach parity. and removed Feature: Go to Definition An issue related to Go to Definition/Declaration. Language Service bug verified Bug has been reproduced labels Sep 26, 2019
@sean-mcmanus sean-mcmanus added this to the 0.26.1 milestone Sep 26, 2019
@sean-mcmanus sean-mcmanus added Visual Studio Inherited from Visual Studio and removed Works in VS So we'd need to fix it for VS Code to reach parity. labels Sep 27, 2019
@sean-mcmanus sean-mcmanus modified the milestones: 0.26.1, On Deck Sep 27, 2019
@sean-mcmanus
Copy link
Collaborator

Thanks for reporting this. The bug also repros in VS, so I've filed a bug at https://developercommunity.visualstudio.com/content/problem/752497/cc-intellisense-based-go-to-definition-fails-for-m.html . You could upvote that if you have a Microsoft account.

@sean-mcmanus sean-mcmanus removed this from the On Deck milestone Sep 27, 2019
@smwikipedia
Copy link
Author

Thanks. So Visual Studio and Visual Studio Code share some implementations?

@smwikipedia
Copy link
Author

smwikipedia commented Sep 30, 2019

I have upvoted that VS bug report. I see this issue was removed from the 0.26.1 milestone. Kind of disappointing. Could you reveal if it will be covered in any future milestones? Thanks. @sean-mcmanus

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Sep 30, 2019

Yeah, our low level parsing and IntelliSense code is shared. We plan to share more later.

It was removed from 0.26.1 because we don't know when the fix will get in -- it depends on when the VC++ team decides to fix. I was able to fix it for your specific repro via changing a hard-coded array size, but I don't think that is the correct fix.

@bobbrow bobbrow added this to the Tracking milestone Oct 3, 2019
@sean-mcmanus sean-mcmanus modified the milestones: Tracking, 1.3.0 Feb 3, 2021
@sean-mcmanus sean-mcmanus added the fixed Check the Milestone for the release in which the fix is or will be available. label Feb 3, 2021
@Colengms
Copy link
Collaborator

@sean-mcmanus Did this make it into 1.2.1 ?

@sean-mcmanus
Copy link
Collaborator

No. It's for 1.3.0-insiders.

@sean-mcmanus
Copy link
Collaborator

@smwikipedia
Copy link
Author

Glad it is claimed to be fixed.

@michelleangela
Copy link
Contributor

Fix is released in the 1.3.0 release version https://github.com/microsoft/vscode-cpptools/releases/tag/1.3.0

@github-actions github-actions bot locked and limited conversation to collaborators May 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Feature: Go to Definition An issue related to Go to Definition/Declaration. 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