Skip to content
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

Add normalizer tests for @dim attributes. #14

Draft
wants to merge 5 commits into
base: devel
Choose a base branch
from

Conversation

@@ -0,0 +1,23 @@
typedef [[okl::dim("(4,4)")]] float *mat4;
Copy link
Collaborator Author

@kchabSS kchabSS Jan 31, 2024

Choose a reason for hiding this comment

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

It is expected that type attributes are added just before the type itself by default

Copy link
Collaborator

Choose a reason for hiding this comment

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

One of the main purpose of normalizer is to unify using of attribute in terms of location.

[[okl::dim("(4,4)")]] typedef float *mat4;

is completely valid syntax without changing semantic.

Multivar declarations is the corner case and is broken by design regarding standard attributes.
To address this special case the multivar will be splitted into single var using clang-tidy with readability-isolate-declaration fixit.

Copy link
Collaborator Author

@kchabSS kchabSS Feb 1, 2024

Choose a reason for hiding this comment

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

One of the main purpose of normalizer is to unify using of attribute in terms of location.

[[okl::dim("(4,4)")]] typedef float *mat4;

is completely valid syntax without changing semantic.

Multivar declarations is the corner case and is broken by design regarding standard attributes. To address this special case the multivar will be splitted into single var using clang-tidy with readability-isolate-declaration fixit.

The above statement is totally wrong.
typedefs can define multiple 'aliases' to the same base type.
By definition, they are part of one.

Here we have a few solutions:

  • Write attribute before the type: typedef [[]] int A, *B
  • Write attribute(s) before or after the declaration: typedef int A [[]], *B [[]]
  • Do not change attribute position: typedef [[]] int A, *B

The second one duplicates the attribute changing it's nature from type attribute to decl attribute.
The last one works fine for most cases because we treat special case attributes as type attributes anyway.

// Multiple
{
[[okl::dim("(x,y)")]] int arr1_1[12], arr1_2[12];
int [[okl::dim("(x,y)")]] arr2_1[12], arr2_2[12];
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Attribute type must be applied only to the first definition.


// Multiple
{
[[okl::dim("(x,y)")]] int arr1_1[12], arr1_2[12];
Copy link
Collaborator Author

@kchabSS kchabSS Jan 31, 2024

Choose a reason for hiding this comment

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

If the same attribute applied to both variables, it must be positioned at the beginning before type.

{
[[okl::dim("(x,y)")]] int arr1_1[12], arr1_2[12];
int [[okl::dim("(x,y)")]] arr2_1[12], arr2_2[12];
int [[okl::dim("(x,y)")]] arr3_1[12], [[okl::dim("(y,x)")]] arr3_2[12];
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Two different attributes on single multi-definition.
Each attribute must be just shy before the variable name.

@@ -0,0 +1,26 @@
typedef [[okl::dim("(4,5)")]] int *iPtr45;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Type attribute must be placed before the type itself.
OR before the variable/type name in case of multiple variable/type definitions per single declaration.

tests/functional/main.cpp Outdated Show resolved Hide resolved
@kchabSS kchabSS marked this pull request as draft March 28, 2024 13:29
@kchabSS kchabSS changed the title Draft: Add normalizer tests for @dim attributes. Add normalizer tests for @dim attributes. Mar 28, 2024
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