Add workaround for misparsed casts#767
Draft
schuessf wants to merge 5 commits into
Draft
Conversation
Contributor
|
Thanks for looking into this issue! However, I am quite hesitant about this workaround. It seems like a dangerous route to just accept that our parser yields nonsensical ASTs and then to retroactively try and reconstruct what the correct AST would be. I worry that this will be a challenge to maintain: who knows how many of these special cases we will start to add, whether they will behave consistently across dependency (parser) updates, what unintended side effects they might have on cases where the AST actually correctly represents the code, etc. Especially now that we are not shortly before a major deadline that is hugely impacted by this bug, I think we should rather try to find a cleaner solution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Recently, we added some support for non-preprocessed files wrt. system includes. To do so, our implementations of
ILibraryModelcontain definitions of macros, functions and types defined in those includes, modeled in Boogie. However, we don't actually handle the includes, therefore they are unknown to the CDT parser. While this works fine for most of the cases, a cast with a type only defined in a system header, where the expression to be casted (such as(size_t) (x)) is actually parsed as a function call. Therefore, we may crash when handling this "function call", since the function name (i.e., the actual type name) is not known.As a workaround, this PR identifies such "function calls" that are misparsed casts (i.e., function calls, where the "name" is a type in our library models that is in brackets) and handles them the same way as casts are usually handled. To do so, the code for handling casts was slightly refactored and simplified.