-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: devel
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,23 @@ | |||
typedef [[okl::dim("(4,4)")]] float *mat4; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
@dim
attributes.@dim
attributes.
Draft for the time being*
Type attributes are based on
attributed_type
described in:C++ syntax:
https://discourse.llvm.org/t/rfc-new-attribute-annotate-type-iteration-2/61378
https://discourse.llvm.org/t/rfc-lifetime-annotations-for-c/61377
https://discourse.llvm.org/t/rfc-new-attribute-annotate-type/59076
GNU Syntax:
https://software-dl.ti.com/codegen/docs/tiarmclang/compiler_tools_user_guide/compiler_manual/c_cpp_language_implementation/attributes/type_attributes.html