[oslcomp] Reworked source location to include column numbers #2006
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.
Description
Touched up lexer and parser so that for each AST node created the start/end line and columns are recorded.
A new object called SrcLoc has been introduced that records the filename together with these 4 numbers,
and the code has been updated to make direct use of this new entity.
Diagnostics from the compiler are now followed by a print out of where the error occurred, and a "squiggle underline"
pointing at the diagnosed offender.
Defect: at the moment, the print out uses before-preprocessing code, while the lexer can only track locations after preprocessing. This means that if macros are involved that alter the spacing, the squiggles will be in the wrong place.
Until we get a preprocessing frontend that tells us about the pre-substitution locations, this cannot be fixed.
Tests
No new tests have been added
Checklist:
already run clang-format v17 before submitting, I definitely will look at
the CI test that runs clang-format and fix anything that it highlights as
being nonconforming.