Skip to content

C++: Support C23 typeof and typeof_unqual #19290

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

Merged
merged 5 commits into from
Apr 24, 2025
Merged

C++: Support C23 typeof and typeof_unqual #19290

merged 5 commits into from
Apr 24, 2025

Conversation

jketema
Copy link
Contributor

@jketema jketema commented Apr 11, 2025

No description provided.

@github-actions github-actions bot added the C++ label Apr 11, 2025
@jketema jketema changed the title C++: Support C23's typeof and typeof_unqual C++: Support C23 typeof and typeof_unqual Apr 11, 2025
@jketema jketema force-pushed the typeof branch 3 times, most recently from c95523d to 1849b4c Compare April 11, 2025 20:49
@jketema jketema added the depends on internal PR This PR should only be merged in sync with an internal Semmle PR label Apr 11, 2025
@jketema jketema marked this pull request as ready for review April 23, 2025 15:24
@jketema jketema requested a review from a team as a code owner April 23, 2025 15:24
Comment on lines +1 to +11
class Type extends @type {
string toString() { none() }
}

class Expr extends @expr {
string toString() { none() }
}

from Type decltype, Expr expr, Type basetype, boolean parentheses
where decltypes(decltype, expr, _, basetype, parentheses)
select decltype, expr, basetype, parentheses
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK this kind of projection can be written directly in the properties file by means of the reorder operator, without writing a ql file:

decltypes.rel: reorder decltypes.rel (int id, int expr, int kind, int basetype, boolean paren) id expr basetype paren

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Leaving this as is, but I'll keep this in mind when it ever comes up again.


predicate typeTransformation(Type type, string name, int kind, Type type_id) {
type_operators(type, _, _, type_id) and
name = "" and
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing this name = "" means losing some information, but we're accepting that, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really. I'm just projecting all the rows of the type_operators table on the derivedtypes table, to make sure I have some kind of type, but the derivedtypes table requires me to make up some kind of name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could compute something based on the two columns of type_operators that I ignore here, but that doesn't seem to be worth the trouble.

Copy link
Contributor

@redsun82 redsun82 left a comment

Choose a reason for hiding this comment

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

LGTM, only a downgrade script suggestion and a doubt, but nothing blocking 👍

@jketema jketema merged commit 4093afb into github:main Apr 24, 2025
13 of 17 checks passed
@jketema jketema deleted the typeof branch April 24, 2025 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ depends on internal PR This PR should only be merged in sync with an internal Semmle PR documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants