Skip to content

Fix #684: Keep line directives in tokenized output#685

Open
glankk wants to merge 7 commits into
cppcheck-opensource:masterfrom
glankk:684
Open

Fix #684: Keep line directives in tokenized output#685
glankk wants to merge 7 commits into
cppcheck-opensource:masterfrom
glankk:684

Conversation

@glankk

@glankk glankk commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

The lineDirective function is not really needed after this change and has been removed. A locationchange flag has been added to the Token class to keep track of when a location discontinuity occurs, this is needed for gotoNextLine to still work correctly during preprocessing when #line moves back to the same line it is already at.

@glankk glankk changed the title Keep line directives in tokenized output Fix #684: Keep line directives in tokenized output Jul 20, 2026
@glankk

glankk commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator Author

There are some issues with how simplecpp currently handles directives and locations with respect to lines. The sameline function that is used in many places only checks the logical location of tokens which is affected by line directives. So for example, the following was until now treated as a valid include directive:

#
#line 1
include
#line 1
"header.h"

This won't be the case after this change because the line directives are kept in the raw tokens, but I think that's alright because I don't think this is inteded to begin with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant