-
Notifications
You must be signed in to change notification settings - Fork 80
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
Rewrite parameter uses when rewriting function types. #484
Comments
dtarditi
added a commit
that referenced
this issue
Oct 19, 2018
Change the transformation of positional parameters in TreeTransform.h to use the transformed types for parameters. Do this by using the types passed into TransformExtendedParameterInfo. Before this, the code was just transforming the type for the positional parameter based on however types were being transformed., This worked fine for a type-only transform, but didn't work properly when the parameter type was transformed based on some other informaton in the program (such as a bounds-safe interface). This fixes issue #484. Testing: - Add a regression test based on the case described in issue #484.
dtarditi
added a commit
that referenced
this issue
Oct 20, 2018
In TreeTransform.h, track the transformed types for parameters. Use this information to update the types for positional parameter expressions. This fixes issue #484, which was a typechecking error caused by different types for uses of parameters in bounds expressions in function types. The tracking is straightforward: we add a vector of types for parameters. Positional parameters only occur in bounds expressions in types. When we transform a function prototype type, we record the transformed types for parameters before transforming the bounds expressions in the types. This change also contains a few clean up changes: 1. While debugging an alternative approach, I noticed that TreeTransform had some code that is flagged as specific to template instantiation. It was mostly code for marking uses. The code in turn called into code that checked for detecting references to local variables defined in other lexical contexts (for example, block scopes). Those checks depend on the lexical context state for Sema. We don't want any of this code running for the kinds of transforms that we are doing, so I added a new method to TreeTransform.h that can be overridden to suppress this code. 2. Clean up and improve some comments in TreeTransform.h. 3. Improve the parameters for TransformExtendedParameterInfo, marking some as const and changing the order of parameters to group related parameters together. Testing: - Added new regression test for issue 484. - Passed local testing on Windows. - Passed automated testing.
Fixed by PR #576. |
sulekhark
pushed a commit
that referenced
this issue
Jul 8, 2021
Before this change, types for function pointer parameters were generated from a QualType object even when the specific parameter was not changed by 3c. Now parameters that 3c does not convert will be rewritten using their original source representation. This fixes #484 by using va_list for the parameter (how it's written in the source) instead of expanding it to struct __va_list_tag *. As a side effect, this preserves formatting in function pointer types slightly better than before. This shows up mostly as spaces being deleted from our generated tests.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In checked scopes , we rewrite function types with bounds-safe interfaces to be fully checked. We need to rewrite declarations of parameters and uses of parameters that have bounds-safe interfaces.
The following example illustrates the problem. We define 3 C typedefs:
We define a function that returns 1, with a bounds-safe interface of 2. We try to assign the result to 3 and get a compiler error that makes no sense on the face of it:
Here is the compiler error:
My guess is that the uses of a in bsi_callback_fn3 weren't rewritten, causing the types to differ for reasons that aren't apparent in the error message.
The text was updated successfully, but these errors were encountered: