Add line marker after macro expansion #27
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds a line marker to the end of a macro expansion to fix the line numbers of the code that follows the macro call.
I am not at all sure whether this is the best approach to solve this problem as I have little experience with the forms of macros that appear in Haskell code. However, I have tested this variant of
cpphs
with the 100 Haskell projects on GitHub with most stars and did not discover any problems in highlighting at least the top-level identifiers in the original source files, where the source positions were taken from the preprocessed file.The problem that motivated this pull request was caused by https://github.com/clash-lang/clash-compiler/blob/47b8fa7c84825f94c3c84b3428f6766c8391f899/clash-lib/src/Clash/Core/Subst.hs#L448 and the macro at https://github.com/clash-lang/clash-compiler/blob/47b8fa7c84825f94c3c84b3428f6766c8391f899/clash-lib/src/ClashDebug.h#L5. In this example, the source positions of https://github.com/clash-lang/clash-compiler/blob/47b8fa7c84825f94c3c84b3428f6766c8391f899/clash-lib/src/Clash/Core/Subst.hs#L458 and all following are wrong.