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

Incorrectly handled foreach style loops #509

Open
mcserep opened this issue Jan 31, 2021 · 5 comments · May be fixed by #591
Open

Incorrectly handled foreach style loops #509

mcserep opened this issue Jan 31, 2021 · 5 comments · May be fixed by #591
Assignees
Labels
Kind: Bug ⚠️ Level: Intermediate (3) Plugin: C++ Issues related to the parsing and presentation of C++ projects.

Comments

@mcserep
Copy link
Collaborator

mcserep commented Jan 31, 2021

It seems CodeCompass handles foreach style for loops incorrectly when clicking on the enumerated variable.

How to reproduce:

@mcserep mcserep added Kind: Bug ⚠️ Plugin: C++ Issues related to the parsing and presentation of C++ projects. labels Jan 31, 2021
@mcserep mcserep added this to the Release Flash milestone Jan 31, 2021
@mcserep mcserep added this to To do in Roadmap via automation Jan 31, 2021
@zsofiaschell
Copy link
Collaborator

zsofiaschell commented Oct 27, 2022

The problem only occurs, when clicking in a for cycle. If clicking on the same parameter somewhere else, it works perfectly.
A C++11 Range-Based For-Loop is represented by CXXForRangeStmt.

@whisperity
Copy link
Member

This is still a bit weird. If the foreach is not in a lambda (#583) then right now then examples from CodeCompass itself work for me (Firefox, Ubuntu):
Clicking loop variable inside the loop highlights all use cases and the definition
(Note that the syntax highlight is wonky.)

However, clicking on the iterable of the foreach, now that is definitely broken:
Clicking on iterable (input of the loop) does not highlight anything, and the InfoTree is filled with junk
Clicking on the iterable somewhere else highlights all occurrences, but the loop.


The PCL source code's parsing status broke since the creation of the ticket.

@mcserep
Copy link
Collaborator Author

mcserep commented Nov 3, 2022

The PCL source code's parsing status broke since the creation of the ticket.

@whisperity Fixed it, the dependencies changed a little bit. The corresponding lines are 94 and 98 now.
https://codecompass.net/demo/#wsid=PCL&fid=16855117887643076224

@zsofiaschell
Copy link
Collaborator

Tried to reproduce the issue on a smaller project.
I will attach the example code and the ast.

example.txt
ast.txt

@zsofiaschell
Copy link
Collaborator

Hi!
Created another example without using std and the iostream include (see in the attachments).

I found in clang's AstVisitor functions named TraverseForStmt and TraverseCXXForRangeStmt:

  • bool TraverseForStmt(clang::ForStmt *forStmt)
  • bool TraverseCXXForRangeStmt (clang::CXXForRangeStmt *forRangeStmt).

I think we will need the second one for the foreach cycle, maybe.

example_code.txt
ast_new.txt

@zsofiaschell zsofiaschell linked a pull request Feb 10, 2023 that will close this issue
@mcserep mcserep added this to To do in Lab via automation Sep 20, 2023
@mcserep mcserep modified the milestones: Release Gershwin, Release H* Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Kind: Bug ⚠️ Level: Intermediate (3) Plugin: C++ Issues related to the parsing and presentation of C++ projects.
Projects
Lab
To do
Roadmap
To do
Development

Successfully merging a pull request may close this issue.

4 participants