Skip to content

[LLVM][IR] Switch from manual pointer incrementation to function in Lexer #152103

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Bertik23
Copy link
Contributor

@Bertik23 Bertik23 commented Aug 5, 2025

The IR Lexer has a getNextChar() function implemented. But it is used only once, on other places the pointer pointing to the current position in the lexed string (CurPtr) is incremented manually, this can lead to some OOB errors (see #151556 and Discourse thread).

To mitigate the issue, this PR changes the getNextChar() to be more straight forward, changes all manual pointer increments to getNextChar() or adds checks, so that no OOB occurs.

Two helper functions were used skipNChars and advancePositionTo. Where skipNChars(N) calls getNextChar() N-times, while advancePositionTo(Ptr) is used insead of CurPtr = Ptr.

One helper function isLabelTail was moved into the Lexer class, to be able to check the bounds, and renamed to getLabelTail to better reflect it's function.

@Bertik23
Copy link
Contributor Author

Bertik23 commented Aug 7, 2025

Ping @nikic as I haven't found a IR specific maintainer

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