Skip to content

Insert itypes for parameters with typedef types #690

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 3 commits into from
Aug 27, 2021
Merged

Conversation

john-h-kastner
Copy link
Collaborator

@john-h-kastner john-h-kastner commented Aug 25, 2021

This allows a function using an otherwise unchecked typedef type to expose an checked interface. It also lets a function use a typedef'ed parameter unsafely without forcing the entire typedef to be unchecked.

In the following example, the typedef td is unchecked because of the unsafe use of b. Prior to this change, test would not be rewritten, leaving it with a fully unchecked type. The new rewriting is void test (td a : itype(_Ptr<int>)).

typedef int *td;
void test(td a) {
  td b = 1;
}

In the other direction, the parameter a can be used unsafely, but the typedef will still be rewritten to _Ptr<int>, and the parameter will get an itype int * : itype(td).

typedef int *td;
void test(td a) {
  a = 1;
}

This allows a function using an otherwise unchecked typedef type expose
an checked interface. It also lets a function use a typedef'ed parameter
unsafely without forcing the entire typedef to be unchecked.
Copy link
Collaborator

@aaronjeline aaronjeline left a comment

Choose a reason for hiding this comment

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

Looks great. More elegant to get rid of the TypedefType object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants