Skip to content

A7-1-7: Exclude anonymous structs #630

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

Closed
lcartey opened this issue Jun 26, 2024 · 1 comment · Fixed by #634
Closed

A7-1-7: Exclude anonymous structs #630

lcartey opened this issue Jun 26, 2024 · 1 comment · Fixed by #634
Assignees
Labels
Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Medium Phase III Standard-AUTOSAR

Comments

@lcartey
Copy link
Collaborator

lcartey commented Jun 26, 2024

Affected rules

  • A7-1-7

Description

Anonymous structs are considered a type declaration in our database, but they are usually combined with other declarations by necessity (otherwise it is impossible to later refer to the struct). We should therefore exclude such anonymous structs from the query.

Example

typedef struct x { int y }; z;
@lcartey lcartey added Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Medium labels Jun 26, 2024
@lcartey lcartey moved this from Reported to Triaged in Coding Standards Public Development Board Jun 26, 2024
@knewbury01 knewbury01 self-assigned this Jul 4, 2024
@knewbury01
Copy link
Contributor

knewbury01 commented Jul 4, 2024

not sure if this example has anything labelled anonymous (in the database or otherwise)

for example:

// clang-format off
typedef struct x { int y; } z; //COMPLIANT
// clang-format on

struct OuterStruct {
  struct {
    int val[10]; // COMPLIANT
  } firstArray;

  struct {
    int val[10][2]; // COMPLIANT
  } secondArray;
};

run with:

from Declaration d
where d.(UserType).isAnonymous()
select d

shows only the nested structs (and the definition of anonymous here suggests that unnamed structs only are anon) - the struct example in the report has a name

this still has the typedef problem though, so I think what we want here is actually to omit cases where TypeDeclarationEntry's exist on the same line? (the declaration of z is on the same line as the definition of x)

this will still yield an alert for the definition of y though, and not sure if we want to then begin permitting structs to generally be defined on one line . I think not, so I will only only omit the extra alerts from the typedef related pieces

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address false positive/false negative An issue related to observed false positives or false negatives. Impact-Medium Phase III Standard-AUTOSAR
Projects
Development

Successfully merging a pull request may close this issue.

3 participants