Incorrectly handled foreach style loops
It seems CodeCompass handles foreach style for loops incorrectly when clicking on the enumerated variable.
How to reproduce:
- In the PCL source code click on
centroids_in line 97. or oncentroidin line 101. In the InfoTree, the complete functions is shown, and the goto definition feature also work in correctly. https://codecompass.net/demo/#wsid=PCL&fid=16855117887643076224&select=97|1|98|1¢er=text - In the CodeCompass source click
_ctx.fileStatusin line 358. to get the very same issue: https://codecompass.net/demo/#wsid=CodeCompass&fid=3022161984525021070&select=358|1|359|1¢er=text
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.
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):
(Note that the syntax highlight is wonky.)
However, clicking on the iterable of the foreach, now that is definitely broken:

The PCL source code's parsing status broke since the creation of the ticket.
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
Tried to reproduce the issue on a smaller project. I will attach the example code and the ast.
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.