Skip to content

C++: Fix duplicate result types#3548

Merged
rdmarsh2 merged 1 commit into
github:masterfrom
dbartol:github/codeql-c-analysis-team/69
May 26, 2020
Merged

C++: Fix duplicate result types#3548
rdmarsh2 merged 1 commit into
github:masterfrom
dbartol:github/codeql-c-analysis-team/69

Conversation

@dbartol
Copy link
Copy Markdown

@dbartol dbartol commented May 22, 2020

I hit this while working on a different change. @rdmarsh2, this might (silently) affect your work on modeling this as a variable, because the type &this is going to be glval<unknown>.

In a couple of cases, we use glval<unknown> as the result type of an instruction because we can't come up with anything better. Two examples are the result of VariableAddress[#ellipsis], and the address of the temp variable that holds the lvalue result of the conditional operator in (a ? b : c) = y. In both cases, we call getTypeForGLValue(any(UnknownType t)), but that would have multiple results because result.hasType(any(UnknownType t), true) also holds for CppFunctionGLValueType. I tightened the result type to ensure we get the right one.

In a couple of cases, we use `glval<unknown>` as the result type of an instruction because we can't come up with anything better. Two examples are the result of `VariableAddress[#ellipsis]`, and the address of the temp variable that holds the lvalue result of the conditional operator in `(a ? b : c) = y`. In both cases, we call `getTypeForGLValue(any(UnknownType t))`, but that would have multiple results because `result.hasType(any(UnknownType t), true)` also holds for `CppFunctionGLValueType`. I tightened the result type to ensure we get the right one.
@dbartol dbartol added the C++ label May 22, 2020
@dbartol dbartol requested a review from rdmarsh2 May 22, 2020 20:51
@dbartol dbartol requested a review from a team as a code owner May 22, 2020 20:51
Copy link
Copy Markdown
Contributor

@rdmarsh2 rdmarsh2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rdmarsh2 rdmarsh2 merged commit 2429e22 into github:master May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants