-
Notifications
You must be signed in to change notification settings - Fork 745
Improve LLVM bug 9069 workaround #804
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
Comments
Actually, wouldn't detecting that and always removing the last token fail if the macro declaration is the last thing in the file? I guess improving this only allows us to avoid trying without the token if we detect the bug is not present. |
Hmm, yes, you're right. Unconditionally removing the last token if you detect the bug is not sufficient. This is why instead of working around the bug at the token level, in cexpr I look at it at the range level. In the buggy case, the range does extend past the end of the file, but since there is no data there, no extra token is returned. Adjusting the range always fixes the bug. This also matches the bug fix of LLVM itself. |
This bug would be closed by #1807. |
Due to LLVM bug 9069, an extra token is included when tokenizing ranges. This is used to parse macros. This bug is fixed in LLVM 4.0.
Our current workaround just tries parsing the macro twice, removing the last token if it failed the first time. This is not very robust and can result in unwanted behavior:
In the
cexpr
tests, instead we check which behavior we get at runtime by checking the result of parsing a know macro: jethrogb/rust-cexpr@0ea1367 . @emilio suggested the same could be implemented here with a CXUnsavedFile.The text was updated successfully, but these errors were encountered: