C++: Tests for variables with ambiguous types#2970
Merged
MathiasVP merged 1 commit intogithub:masterfrom Mar 11, 2020
Merged
Conversation
nickrolfe
reviewed
Mar 3, 2020
| // BUG: types of members depend on extraction order. | ||
| // Only one copy of this struct is extracted, and the types of its members refer | ||
| // to the typedefs in file1.c. Had file2.c been extracted first instead, the | ||
| // types of its members would be different. |
Contributor
There was a problem hiding this comment.
That sounds right, and is similar to the way that the existing variables/global test would produce different output if a.c and b.c got extracted in a different order.
nickrolfe
reviewed
Mar 3, 2020
| // The type of `structMember` is ambiguous, and the two possible types are not | ||
| // unifiable, meaning in this context that they don't share an unspecified type. | ||
| // The types are nevertheless _compatible_, so it's valid C (not C++) to use | ||
| // these two definitions interchangably in the same program. |
Contributor
There was a problem hiding this comment.
Right. The content hashes for NotUnifiableTwice include the name emptyStruct1 or emptyStruct2, which is how they end up differing.
nickrolfe
reviewed
Mar 3, 2020
Contributor
nickrolfe
left a comment
There was a problem hiding this comment.
The comments you've added look right to me, and correspond with my understanding of the extractor and QL library's behaviour.
MathiasVP
approved these changes
Mar 11, 2020
Contributor
MathiasVP
left a comment
There was a problem hiding this comment.
It sounds like it "Looks Good To Nick"
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.
We've worked around several issues with malformed IR due to malformed databases (#2821, #2844, #2835), and some of these workarounds should be replaced with fixes at a deeper level.
This PR is an attempt to understand why variables (and therefore expressions) can get multiple types. Hopefully that will get us closer to proposing and implementing a fix, either at the extractor level or the QL level.